import * as i0 from '@angular/core';
import { Component, Input, Injectable, Pipe, ContentChildren, ContentChild, NgModule, EventEmitter, HostListener, ViewChild, Output, ViewChildren, ViewContainerRef } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import { Subject, debounceTime } from 'rxjs';
import * as i3 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import morphdom from 'morphdom';
import markdownit from 'markdown-it';
import { getDefaultWhiteList, getDefaultCSSWhiteList, filterXSS } from 'xss';
import hljs from 'highlight.js';

class BubbleLoadingComponent {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleLoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: BubbleLoadingComponent, isStandalone: true, selector: "mc-bubble-loading", ngImport: i0, template: "<div class=\"mc-bubble-loading\">\r\n  <div class=\"loading-dot dot-start\"></div>\r\n  <div class=\"loading-dot dot-middle\"></div>\r\n  <div class=\"loading-dot dot-end\"></div>\r\n</div>", styles: [".mc-bubble-loading{display:flex;align-items:center;gap:8px}.mc-bubble-loading .loading-dot{width:8px;height:8px;border-radius:5px;background-color:#9880ff}.mc-bubble-loading .loading-dot.dot-start{animation:dotFlashing 1s infinite linear alternate;animation-delay:0s}.mc-bubble-loading .loading-dot.dot-middle{animation:dotFlashing 1s infinite linear alternate;animation-delay:.5s}.mc-bubble-loading .loading-dot.dot-end{animation:dotFlashing 1s infinite linear alternate;animation-delay:1s}@keyframes dotFlashing{0%{background-color:#9880ff}to{background-color:#ebe6ff}}\n"] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleLoadingComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-bubble-loading', standalone: true, template: "<div class=\"mc-bubble-loading\">\r\n  <div class=\"loading-dot dot-start\"></div>\r\n  <div class=\"loading-dot dot-middle\"></div>\r\n  <div class=\"loading-dot dot-end\"></div>\r\n</div>", styles: [".mc-bubble-loading{display:flex;align-items:center;gap:8px}.mc-bubble-loading .loading-dot{width:8px;height:8px;border-radius:5px;background-color:#9880ff}.mc-bubble-loading .loading-dot.dot-start{animation:dotFlashing 1s infinite linear alternate;animation-delay:0s}.mc-bubble-loading .loading-dot.dot-middle{animation:dotFlashing 1s infinite linear alternate;animation-delay:.5s}.mc-bubble-loading .loading-dot.dot-end{animation:dotFlashing 1s infinite linear alternate;animation-delay:1s}@keyframes dotFlashing{0%{background-color:#9880ff}to{background-color:#ebe6ff}}\n"] }]
        }] });

class AvatarBodyIconComponent {
    constructor() {
        this.width = 16;
        this.height = 16;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarBodyIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: AvatarBodyIconComponent, isStandalone: true, selector: "mc-avatar-body-icon", inputs: { width: "width", height: "height" }, ngImport: i0, template: "<svg\r\n  [style.width.px]=\"width\"\r\n  [style.height.px]=\"height\"\r\n  style=\"vertical-align: middle;\"\r\n  viewBox=\"0 0 30 30\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <circle id=\"Oval\" fill=\"#CACFD8\" cx=\"15\" cy=\"15\" r=\"15\"></circle>\r\n    <path\r\n      d=\"M14.9997866,16 C12.5145053,16 10.4997866,13.9852814 10.4997866, 11.5 C10.4997866,9.01471863 12.5145053,7 14.9997866,7 C17.485068, 7 19.4997866,9.01471863 19.4997866,11.5 C19.4997866,13.9852814 17.485068, 16 14.9997866,16 Z M23,23 L7,22.998553 C7,19.0122153 10.8892296, 16.5 14.9997866,16.5 C19.1103437,16.5 23,20 23,23 Z\"\r\n      fill=\"#FFFFFF\"\r\n    ></path>\r\n  </g>\r\n</svg>", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarBodyIconComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-avatar-body-icon', standalone: true, template: "<svg\r\n  [style.width.px]=\"width\"\r\n  [style.height.px]=\"height\"\r\n  style=\"vertical-align: middle;\"\r\n  viewBox=\"0 0 30 30\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <circle id=\"Oval\" fill=\"#CACFD8\" cx=\"15\" cy=\"15\" r=\"15\"></circle>\r\n    <path\r\n      d=\"M14.9997866,16 C12.5145053,16 10.4997866,13.9852814 10.4997866, 11.5 C10.4997866,9.01471863 12.5145053,7 14.9997866,7 C17.485068, 7 19.4997866,9.01471863 19.4997866,11.5 C19.4997866,13.9852814 17.485068, 16 14.9997866,16 Z M23,23 L7,22.998553 C7,19.0122153 10.8892296, 16.5 14.9997866,16.5 C19.1103437,16.5 23,20 23,23 Z\"\r\n      fill=\"#FFFFFF\"\r\n    ></path>\r\n  </g>\r\n</svg>" }]
        }], propDecorators: { width: [{
                type: Input
            }], height: [{
                type: Input
            }] } });

class AvatarNoBodyIconComponent {
    constructor() {
        this.width = 16;
        this.height = 16;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarNoBodyIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: AvatarNoBodyIconComponent, isStandalone: true, selector: "mc-avatar-no-body-icon", inputs: { width: "width", height: "height" }, ngImport: i0, template: "<svg\r\n  [style.width.px]=\"width\"\r\n  [style.height.px]=\"height\"\r\n  style=\"vertical-align: middle;\"\r\n  viewBox=\"0 0 30 30\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <path\r\n      d=\"M22.31,19.2474562 L22.31,21.9974562 L20.81,21.9974562 L20.81, 19.2474562 L18.06,19.2474562 L18.06,17.7474562 \r\n          L20.81,17.7474562 L20.81, 14.9974562 L22.31,14.9974562 L22.31,17.7474562 L25.06,17.7474562 L25.06, 19.2474562 \r\n          L22.31,19.2474562 Z M14.9297866,14.9974562 C12.4445053, 14.9974562 10.4297866,12.9827376 10.4297866,10.4974562 \r\n          C10.4297866, 8.01217483 12.4445053,5.9974562 14.9297866,5.9974562 C17.415068, 5.9974562 19.4297866,8.01217483 \r\n          19.4297866,10.4974562 C19.4297866, 12.9827376 17.415068,14.9974562 14.9297866,14.9974562 Z M19.6797866, 20.2474562 \r\n          L19.6797866,21.9971623 L6.93,21.9960092 C6.93,18.0096715 10.8192296, 15.4974562 14.9297866,15.4974562 C16.4608397,15.4974562 \r\n          17.9612467,15.983021 19.2414296, 16.7474562 L17.06,16.7474562 L17.06,20.2474562 L19.6797866,20.2474562 Z\"\r\n      fill=\"#959EB2\"\r\n    ></path>\r\n    <path\r\n      d=\"M0,15 L1,15 C1,15.6118966 1.03919561,16.2186526 1.11683409,\r\n            16.8178549 L0.125124012,16.9463505 C0.0425740367,16.309242 0,\r\n            15.6595925 0,15 Z M0.503241262,18.867175 L1.46961749,18.6100428 C1.62594651,\r\n            19.1975718 1.8203704,19.7729973 2.05141295,20.3332823 L1.12693074,\r\n            20.7145074 C0.880599065,20.1171459 0.67172715,19.500393 0.503241262,\r\n            18.867175 Z M1.99122134,22.4730778 L2.85786221,21.9741453 C3.16078316,\r\n            22.5003161 3.49772502,23.0063252 3.86631639,23.4889602 L3.0715754,\r\n            24.0959089 C2.6777461,23.5802273 2.31659753,23.0382531 1.99122134,\r\n            22.4730778 Z M4.38894559,25.6021078 L5.09634867,24.8952974 C5.52582519,\r\n            25.3251341 5.98272136,25.7268214 6.46397085,26.0975793 L5.85367498,\r\n            26.8897529 C5.33779918,26.4923186 4.84851395,26.0620615 4.38894559,\r\n            25.6021078 Z M7.4424647,27.9597887 L7.94703323,27.096417 C8.47111119,\r\n            27.4026968 9.0146817,27.6746032 9.57453904,27.9101878 L9.18668461,\r\n            28.8319084 C8.58423501,28.5784013 8.00181692,28.2866833 7.4424647,\r\n            27.9597887 Z M11.0671021,29.4791103 L11.3286494,28.5139196 C11.9126912,\r\n            28.6721832 12.5080563,28.7925378 13.1119738,28.8738935 L12.9784667,\r\n            29.8649413 C12.3271613,29.7772019 11.6891102,29.647662 11.0671021,\r\n            29.4791103 Z M15,30 C14.9951965,30 14.9903936,29.9999977 14.9855912,\r\n            30 L14.9865313,28.9999937 C14.9929361,28.9999987 14.9929361,\r\n            28.9999987 14.999296,29 C15.6071552,29 16.2093364,28.9614092 16.8041774,\r\n            28.8849313 L16.9316965,29.8767674 C16.2992813,29.9580762 15.6545362,\r\n            30 15,30 Z M18.8545762,29.5001051 L18.5982903,28.5335041 C19.1860387,\r\n            28.3776677 19.7617059,28.1837179 20.3222555,27.9531286 L20.7026875,\r\n            28.8779375 C20.1050484,29.123784 19.4880358,29.3321488 18.8545762,\r\n            29.5001051 Z M22.4608087,28.0158343 L21.9626951,27.1487226 C22.4893928,\r\n            26.8461604 22.9959399,26.5095265 23.479119,26.1411926 L24.0853678,\r\n            26.9364676 C23.5691101,27.3300178 23.0265585,27.6908386 22.4608087,\r\n            28.0158343 Z M25.5921583,25.6209863 L24.8860071,24.9129252 C25.3161421,\r\n            24.4839504 25.7181674,24.0275419 26.0893023,23.5467621 L26.8808873,\r\n            24.1578212 C26.4830546,24.6731862 26.0524368,25.1619493 25.5921583,\r\n            25.6209863 Z M27.9526445,22.5697466 L27.0897495,22.0643633 C27.3964738,\r\n            21.5406601 27.6688549,20.9974409 27.904942,20.4379104 L28.8262855,\r\n            20.8266601 C28.5722411,21.4287497 28.2800163,22.0107897 27.9526445,\r\n            22.5697466 Z M29.4756977,18.9454696 L28.5107363,18.6830777 C28.6695136,\r\n            18.099165 28.7903877,17.5039035 28.8722662,16.9000659 L29.8631978,\r\n            17.0344333 C29.7748946,17.6856516 29.6447979,18.3235936 29.4756977,\r\n            18.9454696 Z M30,15 C30,15.0093541 29.9999914,15.0187063 29.9999743,\r\n            15.0280564 L28.999976,15.0262257 C28.9999956,15.0134169 28.9999956,\r\n            15.0134169 29,15.0006466 C29,14.3970304 28.9619395,13.7989704 28.8865088,\r\n            13.208136 L29.8784576,13.0814959 C29.9586571,13.7096843 30,14.3500145 30,\r\n            15 Z M29.5038108,11.1594275 L28.5369608,11.4147728 C28.3816616,\r\n            10.8267413 28.1882232,10.2507676 27.9581175,9.68988857 L28.8832852,\r\n            9.31033004 C29.1286141,9.90831524 29.3364318,10.5256569 29.5038108,\r\n            11.1594275 Z M28.0228788,7.55146763 L27.1552968,8.0487618 C26.853241,\r\n            7.52179373 26.5170958,7.0149453 26.1492295,6.53143425 L26.9450761,\r\n            5.92593594 C27.3381231,6.44254364 27.6984223,6.98541919 28.0228788,\r\n            7.55146763 Z M25.6309089,4.41780044 L24.9221905,5.12329189 C24.4935639,\r\n            4.69270467 24.0374698,4.2902078 23.5569705,3.9185855 L24.1687554,\r\n            3.12756133 C24.6838129,3.52591118 25.1722392,3.95703271 25.6309089,\r\n            4.41780044 Z M22.5819506,2.05451093 L22.0757531,2.91692851 C21.5523008,\r\n            2.60968727 21.0092999,2.33677531 20.4499564,2.10014728 L20.8395722,\r\n            1.17916981 C21.4414531,1.43379309 22.0232574,1.72658499 22.5819506,\r\n            2.05451093 Z M18.9594329,0.528106464 L18.696103,1.4928123 C18.1122842,\r\n            1.33345081 17.517086,1.21199245 16.9132846,1.12953261 L17.0485964,\r\n            0.138729543 C17.6997753,0.227659622 18.3376514,0.358382523 18.9594329,\r\n            0.528106464 Z M15,-1.11022302e-16 C15.0139048,-1.11022302e-16 15.0278052,\r\n            1.892004e-05 15.0417011,5.673578e-05 L15.0389797,1.00005303 C15.0197685,\r\n            1.00000934 15.0197685,1.00000934 15.0005868,1.00000001 C14.4012162,\r\n            1 13.8072783,1.03753392 13.2204527,1.11192427 L13.0946918,0.119863691 C13.7186509,\r\n            0.0407660189 14.3545651,-1.11022302e-16 15,-1.11022302e-16 Z M11.1720354,\r\n            0.492865376 L11.4265338,1.45993857 C10.8386468,1.61464899 10.2627801,\r\n            1.80746996 9.70196444,2.03693489 L9.32327455,1.11141127 C9.92118954,\r\n            0.86676666 10.5384173,0.659610554 11.1720354,0.492865376 Z M7.56375123,\r\n            1.97008801 L8.06022548,2.83813946 C7.53298826,3.13968806 7.02583975,\r\n            3.47534367 6.54199783,3.84274131 L5.93725081,3.04632368 C6.4542073,\r\n            2.65378102 6.99740556,2.29400434 7.56375123,1.97008801 Z M4.42776842,\r\n            4.35917772 L5.13259949,5.06855291 C4.70156141,5.49682984 4.29859416,\r\n            5.95260763 3.92648544,6.43282469 L3.13602297,5.82031423 C3.53488885,\r\n            5.30556625 3.96651291,4.81747851 4.42776842,4.35917772 Z M2.0616775,\r\n            7.40585279 L2.92361696,7.91286401 C2.61586086,8.43606175 2.34241977,\r\n            8.97884042 2.10525197,9.53799293 L1.18464153,9.14751063 C1.43984243,\r\n            8.54584288 1.73319965,7.96427837 2.0616775,7.40585279 Z M0.531541456,\r\n            11.0280046 L1.49601653,11.2921785 C1.33614878,11.8758413 1.21417484,\r\n            12.4709081 1.13119244,13.074601 L0.140507978,12.9384235 C0.230001486,12.2873626 0.361276825,11.6496255 0.531541456,11.0280046 Z\"\r\n      fill=\"#CACFD8\"\r\n      fill-rule=\"nonzero\"\r\n    ></path>\r\n  </g>\r\n</svg>", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarNoBodyIconComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-avatar-no-body-icon', standalone: true, template: "<svg\r\n  [style.width.px]=\"width\"\r\n  [style.height.px]=\"height\"\r\n  style=\"vertical-align: middle;\"\r\n  viewBox=\"0 0 30 30\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <path\r\n      d=\"M22.31,19.2474562 L22.31,21.9974562 L20.81,21.9974562 L20.81, 19.2474562 L18.06,19.2474562 L18.06,17.7474562 \r\n          L20.81,17.7474562 L20.81, 14.9974562 L22.31,14.9974562 L22.31,17.7474562 L25.06,17.7474562 L25.06, 19.2474562 \r\n          L22.31,19.2474562 Z M14.9297866,14.9974562 C12.4445053, 14.9974562 10.4297866,12.9827376 10.4297866,10.4974562 \r\n          C10.4297866, 8.01217483 12.4445053,5.9974562 14.9297866,5.9974562 C17.415068, 5.9974562 19.4297866,8.01217483 \r\n          19.4297866,10.4974562 C19.4297866, 12.9827376 17.415068,14.9974562 14.9297866,14.9974562 Z M19.6797866, 20.2474562 \r\n          L19.6797866,21.9971623 L6.93,21.9960092 C6.93,18.0096715 10.8192296, 15.4974562 14.9297866,15.4974562 C16.4608397,15.4974562 \r\n          17.9612467,15.983021 19.2414296, 16.7474562 L17.06,16.7474562 L17.06,20.2474562 L19.6797866,20.2474562 Z\"\r\n      fill=\"#959EB2\"\r\n    ></path>\r\n    <path\r\n      d=\"M0,15 L1,15 C1,15.6118966 1.03919561,16.2186526 1.11683409,\r\n            16.8178549 L0.125124012,16.9463505 C0.0425740367,16.309242 0,\r\n            15.6595925 0,15 Z M0.503241262,18.867175 L1.46961749,18.6100428 C1.62594651,\r\n            19.1975718 1.8203704,19.7729973 2.05141295,20.3332823 L1.12693074,\r\n            20.7145074 C0.880599065,20.1171459 0.67172715,19.500393 0.503241262,\r\n            18.867175 Z M1.99122134,22.4730778 L2.85786221,21.9741453 C3.16078316,\r\n            22.5003161 3.49772502,23.0063252 3.86631639,23.4889602 L3.0715754,\r\n            24.0959089 C2.6777461,23.5802273 2.31659753,23.0382531 1.99122134,\r\n            22.4730778 Z M4.38894559,25.6021078 L5.09634867,24.8952974 C5.52582519,\r\n            25.3251341 5.98272136,25.7268214 6.46397085,26.0975793 L5.85367498,\r\n            26.8897529 C5.33779918,26.4923186 4.84851395,26.0620615 4.38894559,\r\n            25.6021078 Z M7.4424647,27.9597887 L7.94703323,27.096417 C8.47111119,\r\n            27.4026968 9.0146817,27.6746032 9.57453904,27.9101878 L9.18668461,\r\n            28.8319084 C8.58423501,28.5784013 8.00181692,28.2866833 7.4424647,\r\n            27.9597887 Z M11.0671021,29.4791103 L11.3286494,28.5139196 C11.9126912,\r\n            28.6721832 12.5080563,28.7925378 13.1119738,28.8738935 L12.9784667,\r\n            29.8649413 C12.3271613,29.7772019 11.6891102,29.647662 11.0671021,\r\n            29.4791103 Z M15,30 C14.9951965,30 14.9903936,29.9999977 14.9855912,\r\n            30 L14.9865313,28.9999937 C14.9929361,28.9999987 14.9929361,\r\n            28.9999987 14.999296,29 C15.6071552,29 16.2093364,28.9614092 16.8041774,\r\n            28.8849313 L16.9316965,29.8767674 C16.2992813,29.9580762 15.6545362,\r\n            30 15,30 Z M18.8545762,29.5001051 L18.5982903,28.5335041 C19.1860387,\r\n            28.3776677 19.7617059,28.1837179 20.3222555,27.9531286 L20.7026875,\r\n            28.8779375 C20.1050484,29.123784 19.4880358,29.3321488 18.8545762,\r\n            29.5001051 Z M22.4608087,28.0158343 L21.9626951,27.1487226 C22.4893928,\r\n            26.8461604 22.9959399,26.5095265 23.479119,26.1411926 L24.0853678,\r\n            26.9364676 C23.5691101,27.3300178 23.0265585,27.6908386 22.4608087,\r\n            28.0158343 Z M25.5921583,25.6209863 L24.8860071,24.9129252 C25.3161421,\r\n            24.4839504 25.7181674,24.0275419 26.0893023,23.5467621 L26.8808873,\r\n            24.1578212 C26.4830546,24.6731862 26.0524368,25.1619493 25.5921583,\r\n            25.6209863 Z M27.9526445,22.5697466 L27.0897495,22.0643633 C27.3964738,\r\n            21.5406601 27.6688549,20.9974409 27.904942,20.4379104 L28.8262855,\r\n            20.8266601 C28.5722411,21.4287497 28.2800163,22.0107897 27.9526445,\r\n            22.5697466 Z M29.4756977,18.9454696 L28.5107363,18.6830777 C28.6695136,\r\n            18.099165 28.7903877,17.5039035 28.8722662,16.9000659 L29.8631978,\r\n            17.0344333 C29.7748946,17.6856516 29.6447979,18.3235936 29.4756977,\r\n            18.9454696 Z M30,15 C30,15.0093541 29.9999914,15.0187063 29.9999743,\r\n            15.0280564 L28.999976,15.0262257 C28.9999956,15.0134169 28.9999956,\r\n            15.0134169 29,15.0006466 C29,14.3970304 28.9619395,13.7989704 28.8865088,\r\n            13.208136 L29.8784576,13.0814959 C29.9586571,13.7096843 30,14.3500145 30,\r\n            15 Z M29.5038108,11.1594275 L28.5369608,11.4147728 C28.3816616,\r\n            10.8267413 28.1882232,10.2507676 27.9581175,9.68988857 L28.8832852,\r\n            9.31033004 C29.1286141,9.90831524 29.3364318,10.5256569 29.5038108,\r\n            11.1594275 Z M28.0228788,7.55146763 L27.1552968,8.0487618 C26.853241,\r\n            7.52179373 26.5170958,7.0149453 26.1492295,6.53143425 L26.9450761,\r\n            5.92593594 C27.3381231,6.44254364 27.6984223,6.98541919 28.0228788,\r\n            7.55146763 Z M25.6309089,4.41780044 L24.9221905,5.12329189 C24.4935639,\r\n            4.69270467 24.0374698,4.2902078 23.5569705,3.9185855 L24.1687554,\r\n            3.12756133 C24.6838129,3.52591118 25.1722392,3.95703271 25.6309089,\r\n            4.41780044 Z M22.5819506,2.05451093 L22.0757531,2.91692851 C21.5523008,\r\n            2.60968727 21.0092999,2.33677531 20.4499564,2.10014728 L20.8395722,\r\n            1.17916981 C21.4414531,1.43379309 22.0232574,1.72658499 22.5819506,\r\n            2.05451093 Z M18.9594329,0.528106464 L18.696103,1.4928123 C18.1122842,\r\n            1.33345081 17.517086,1.21199245 16.9132846,1.12953261 L17.0485964,\r\n            0.138729543 C17.6997753,0.227659622 18.3376514,0.358382523 18.9594329,\r\n            0.528106464 Z M15,-1.11022302e-16 C15.0139048,-1.11022302e-16 15.0278052,\r\n            1.892004e-05 15.0417011,5.673578e-05 L15.0389797,1.00005303 C15.0197685,\r\n            1.00000934 15.0197685,1.00000934 15.0005868,1.00000001 C14.4012162,\r\n            1 13.8072783,1.03753392 13.2204527,1.11192427 L13.0946918,0.119863691 C13.7186509,\r\n            0.0407660189 14.3545651,-1.11022302e-16 15,-1.11022302e-16 Z M11.1720354,\r\n            0.492865376 L11.4265338,1.45993857 C10.8386468,1.61464899 10.2627801,\r\n            1.80746996 9.70196444,2.03693489 L9.32327455,1.11141127 C9.92118954,\r\n            0.86676666 10.5384173,0.659610554 11.1720354,0.492865376 Z M7.56375123,\r\n            1.97008801 L8.06022548,2.83813946 C7.53298826,3.13968806 7.02583975,\r\n            3.47534367 6.54199783,3.84274131 L5.93725081,3.04632368 C6.4542073,\r\n            2.65378102 6.99740556,2.29400434 7.56375123,1.97008801 Z M4.42776842,\r\n            4.35917772 L5.13259949,5.06855291 C4.70156141,5.49682984 4.29859416,\r\n            5.95260763 3.92648544,6.43282469 L3.13602297,5.82031423 C3.53488885,\r\n            5.30556625 3.96651291,4.81747851 4.42776842,4.35917772 Z M2.0616775,\r\n            7.40585279 L2.92361696,7.91286401 C2.61586086,8.43606175 2.34241977,\r\n            8.97884042 2.10525197,9.53799293 L1.18464153,9.14751063 C1.43984243,\r\n            8.54584288 1.73319965,7.96427837 2.0616775,7.40585279 Z M0.531541456,\r\n            11.0280046 L1.49601653,11.2921785 C1.33614878,11.8758413 1.21417484,\r\n            12.4709081 1.13119244,13.074601 L0.140507978,12.9384235 C0.230001486,12.2873626 0.361276825,11.6496255 0.531541456,11.0280046 Z\"\r\n      fill=\"#CACFD8\"\r\n      fill-rule=\"nonzero\"\r\n    ></path>\r\n  </g>\r\n</svg>" }]
        }], propDecorators: { width: [{
                type: Input
            }], height: [{
                type: Input
            }] } });

var zhCN = {
    Input: {
        send: "发送",
        pauseAnswer: "停止回答",
        pleaseEnter: "请输入您的问题...",
        pleaseEnterPlaceholder: "请输入您的问题，并按{enterKey}发送，按{shiftEnterKey}换行",
        ariaLabel: "输入框",
    },
    Md: {
        toggle: "收起/展开",
        copy: "复制",
        diagram: '图形',
        code: '代码',
        zoomIn: '放大',
        zoomOut: '缩小',
        downLoad: '下载',
    },
    Bubble: {
        ariaLabel: "聊天消息气泡",
        emptyAvatar: "无头像占位",
        userName: "用户名称: {name}",
        content: "消息内容",
        avatar: "用户头像: {name}"
    },
};

var enUS = {
    Input: {
        send: "Send",
        pauseAnswer: "Stop",
        pleaseEnter: "Please enter your question...",
        pleaseEnterPlaceholder: "Please enter your question and press {enterKey} to send, {shiftEnterKey} to wrap.",
        ariaLabel: "Input box",
    },
    Md: {
        toggle: "Collapse/Expand",
        copy: "Copy",
        diagram: 'Diagram',
        code: 'Code',
        zoomIn: 'Zoom In',
        zoomOut: 'Zoom Out',
        downLoad: 'Download',
    },
    Bubble: {
        ariaLabel: "Chat message bubble",
        emptyAvatar: "Empty avatar placeholder",
        userName: "User name: {name}",
        content: "Message content",
        avatar: "User avatar: {name}"
    },
};

class LocaleService {
    constructor() {
        // 当前语言
        this._currentLanguage = 'zh-cn';
        // 语言包存储
        this._localeData = new Map();
        // 语言变更通知
        this._languageChange = new Subject();
        // 公开语言变更Observable
        this.languageChange$ = this._languageChange.asObservable();
        // 首先尝试从localStorage获取语言设置
        const savedLang = localStorage.getItem('lang');
        if (savedLang) {
            this._currentLanguage = savedLang;
        }
        // 初始化默认语言包
        this.loadDefaultLocales();
    }
    /**
     * 加载默认语言包
     */
    async loadDefaultLocales() {
        try {
            // 动态导入默认语言包
            this._localeData.set('zh-cn', zhCN);
            this._localeData.set('en-us', enUS);
        }
        catch (error) {
            console.error('Failed to load default locales:', error);
        }
    }
    /**
     * 设置当前语言
     */
    setLanguage(language) {
        if (this._currentLanguage !== language) {
            this._currentLanguage = language;
            // 保存到localStorage
            localStorage.setItem('lang', language);
            this._languageChange.next(language);
        }
    }
    /**
     * 获取当前语言
     */
    getLanguage() {
        return this._currentLanguage;
    }
    /**
     * 翻译文本
     * @param key 翻译键，支持嵌套路径如 'Input.send'
     * @param params 替换参数
     */
    translate(key, params) {
        if (!key)
            return key;
        // 获取当前语言的语言包
        const localeData = this._localeData.get(this._currentLanguage) || {};
        // 解析嵌套键
        const keys = key.split('.');
        let value = localeData;
        for (const k of keys) {
            if (value && typeof value === 'object' && k in value) {
                value = value[k];
            }
            else {
                // 如果键不存在，返回原始键
                return key;
            }
        }
        // 处理替换参数
        if (typeof value === 'string' && params) {
            let result = value;
            for (const [paramKey, paramValue] of Object.entries(params)) {
                const regex = new RegExp(`\\{${paramKey}\\}`, 'g');
                result = result.replace(regex, String(paramValue));
            }
            return result;
        }
        return value;
    }
    /**
     * 添加新的语言
     */
    addLanguage(language, localeData) {
        this._localeData.set(language, localeData);
    }
    /**
     * 覆盖现有语言的部分翻译
     */
    overrideLocale(language, localeData) {
        if (this._localeData.has(language)) {
            const existingLocale = this._localeData.get(language) || {};
            // 深度合并语言包
            const mergedLocale = this.deepMerge(existingLocale, localeData);
            this._localeData.set(language, mergedLocale);
        }
        else {
            // 如果语言不存在，则添加新语言
            this.addLanguage(language, localeData);
        }
    }
    /**
     * 获取所有支持的语言
     */
    getSupportedLanguages() {
        return Array.from(this._localeData.keys());
    }
    /**
     * 深度合并对象
     */
    deepMerge(target, source) {
        const result = { ...target };
        for (const key in source) {
            if (source.hasOwnProperty(key)) {
                if (source[key] instanceof Object && key in target) {
                    result[key] = this.deepMerge(target[key], source[key]);
                }
                else {
                    result[key] = source[key];
                }
            }
        }
        return result;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: () => [] });

/**
 * 翻译管道，用于在Angular模板中直接使用翻译功能
 * 用法：{{ 'Input.send' | translate }}
 * 带参数：{{ 'Input.pleaseEnterPlaceholder' | translate:{ enterKey: 'Enter', shiftEnterKey: 'Shift + Enter' } }}
 */
class TranslatePipe {
    constructor(localeService) {
        this.localeService = localeService;
    }
    /**
     * 转换方法，实现PipeTransform接口
     * @param key 翻译键
     * @param params 替换参数
     */
    transform(key, params) {
        if (!key)
            return key;
        // 调用LocaleService的翻译方法
        return this.localeService.translate(key, params);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: TranslatePipe, deps: [{ token: LocaleService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.10", ngImport: i0, type: TranslatePipe, isStandalone: true, name: "translate", pure: false }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: TranslatePipe }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: TranslatePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'translate',
                    pure: false, // 设置为非纯管道，以便在语言变化时自动更新视图
                    standalone: true // 标记为standalone，以便在standalone组件中直接使用
                }]
        }, {
            type: Injectable
        }], ctorParameters: () => [{ type: LocaleService }] });

class AvatarComponent {
    constructor() {
        this.imgSrc = '';
        this.name = '';
        this.width = 36;
        this.height = 36;
        this.isRound = true;
        this.gender = '';
        this.isErrorImg = false;
        this.isNobody = true;
        this.code = 1;
        this.fontSize = 12;
        this.nameDisplay = '';
    }
    ngOnInit() {
        this.calcValues(this.name);
    }
    ngOnChanges(changes) {
        if (changes['name'] || changes['width'] || changes['height'] || changes['gender']) {
            this.calcValues(this.name);
        }
    }
    onErrorImg() {
        this.isErrorImg = true;
    }
    getBackgroundColor(char) {
        if (this.gender) {
            if (this.gender.toLowerCase() === 'male') {
                this.code = 1;
            }
            else if (this.gender.toLowerCase() === 'female') {
                this.code = 0;
            }
            return;
        }
        const unicode = char.charCodeAt(0);
        this.code = unicode % 2;
    }
    setDisplayName(nameValue, widthValue) {
        if (!nameValue) {
            this.nameDisplay = '';
            return;
        }
        if (nameValue.length < 2) {
            this.nameDisplay = nameValue;
        }
        else {
            // 以中文开头显示最后两个字符
            if (/^[\u4e00-\u9fa5]/.test(nameValue)) {
                this.nameDisplay = nameValue.substr(nameValue.length - 2, 2);
                // 英文开头
            }
            else if (/^[A-Za-z]/.test(nameValue)) {
                // 含有两个及以上，包含空格，下划线，中划线分隔符的英文名取前两个字母的首字母
                if (/[_ -]/.test(nameValue)) {
                    const parts = nameValue.split(/_|-|\s+/);
                    if (parts.length >= 2) {
                        this.nameDisplay = parts[0].substr(0, 1).toUpperCase() + parts[1].substr(0, 1).toUpperCase();
                    }
                    else {
                        this.nameDisplay = nameValue.substr(0, 2).toUpperCase();
                    }
                }
                else {
                    // 一个英文名的情况显示前两个字母
                    this.nameDisplay = nameValue.substr(0, 2).toUpperCase();
                }
            }
            else {
                // 非中英文开头默认取前两个字符
                this.nameDisplay = nameValue.substr(0, 2);
            }
        }
        if (widthValue < 30) {
            this.nameDisplay = nameValue.substr(0, 1).toUpperCase();
        }
        this.getBackgroundColor(nameValue.substr(0, 1));
    }
    calcValues(nameInput) {
        const userName = nameInput;
        const minNum = Math.min(this.width, this.height);
        if (userName) {
            this.isNobody = false;
            this.setDisplayName(userName, minNum);
        }
        else if (userName === '') {
            this.isNobody = false;
            this.nameDisplay = '';
        }
        else {
            this.isNobody = true;
        }
        this.fontSize = minNum / 4 + 3;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: AvatarComponent, isStandalone: true, selector: "mc-avatar", inputs: { imgSrc: "imgSrc", name: "name", width: "width", height: "height", isRound: "isRound", gender: "gender" }, usesOnChanges: true, ngImport: i0, template: "<span class=\"mc-bubble-avatar-wrapper\">\r\n  <img\r\n    *ngIf=\"imgSrc && !isErrorImg\"\r\n    [src]=\"imgSrc\"\r\n    [attr.alt]=\"'Bubble.avatar' | translate:{ name: name }\"\r\n    (error)=\"onErrorImg()\"\r\n    [ngStyle]=\"{\r\n      height: height + 'px',\r\n      width: width + 'px',\r\n      borderRadius: isRound ? '100%' : '0'\r\n    }\"\r\n  />\r\n  <span\r\n    *ngIf=\"!imgSrc && !isNobody && nameDisplay?.length !== 0\"\r\n    [ngClass]=\"['mc-bubble-avatar-style', 'mc-bubble-avatar-background-' + code]\"\r\n    [ngStyle]=\"{\r\n      height: height + 'px',\r\n      width: width + 'px',\r\n      lineHeight: height + 'px',\r\n      fontSize: fontSize + 'px',\r\n      borderRadius: isRound ? '100%' : '0'\r\n    }\"\r\n  >\r\n    {{ nameDisplay }}\r\n  </span>\r\n  <span\r\n    *ngIf=\"!imgSrc && !isNobody && nameDisplay?.length === 0\"\r\n    class=\"mc-bubble-avatar-style\"\r\n    [ngStyle]=\"{ borderRadius: isRound ? '100%' : '0' }\"\r\n  >\r\n    <mc-avatar-body-icon [width]=\"width\" [height]=\"height\" />\r\n  </span>\r\n  <span\r\n    *ngIf=\"(!imgSrc && isNobody) || (imgSrc && isErrorImg)\"\r\n    class=\"mc-bubble-avatar-style\"\r\n    [ngStyle]=\"{ borderRadius: isRound ? '100%' : '0' }\"\r\n  >\r\n    <mc-avatar-no-body-icon [width]=\"width\" [height]=\"height\" />\r\n  </span>\r\n</span>", styles: [".mc-bubble-avatar-wrapper{display:inline-block}.mc-bubble-avatar-wrapper .mc-bubble-avatar-style{display:inline-block;text-align:center;color:var(--devui-light-text, #ffffff)}.mc-bubble-avatar-wrapper .mc-bubble-avatar-background-0{background-color:#ff8b87}.mc-bubble-avatar-wrapper .mc-bubble-avatar-background-1{background-color:#7693f5}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: AvatarBodyIconComponent, selector: "mc-avatar-body-icon", inputs: ["width", "height"] }, { kind: "component", type: AvatarNoBodyIconComponent, selector: "mc-avatar-no-body-icon", inputs: ["width", "height"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: AvatarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-avatar', standalone: true, imports: [CommonModule, AvatarBodyIconComponent, AvatarNoBodyIconComponent, TranslatePipe], template: "<span class=\"mc-bubble-avatar-wrapper\">\r\n  <img\r\n    *ngIf=\"imgSrc && !isErrorImg\"\r\n    [src]=\"imgSrc\"\r\n    [attr.alt]=\"'Bubble.avatar' | translate:{ name: name }\"\r\n    (error)=\"onErrorImg()\"\r\n    [ngStyle]=\"{\r\n      height: height + 'px',\r\n      width: width + 'px',\r\n      borderRadius: isRound ? '100%' : '0'\r\n    }\"\r\n  />\r\n  <span\r\n    *ngIf=\"!imgSrc && !isNobody && nameDisplay?.length !== 0\"\r\n    [ngClass]=\"['mc-bubble-avatar-style', 'mc-bubble-avatar-background-' + code]\"\r\n    [ngStyle]=\"{\r\n      height: height + 'px',\r\n      width: width + 'px',\r\n      lineHeight: height + 'px',\r\n      fontSize: fontSize + 'px',\r\n      borderRadius: isRound ? '100%' : '0'\r\n    }\"\r\n  >\r\n    {{ nameDisplay }}\r\n  </span>\r\n  <span\r\n    *ngIf=\"!imgSrc && !isNobody && nameDisplay?.length === 0\"\r\n    class=\"mc-bubble-avatar-style\"\r\n    [ngStyle]=\"{ borderRadius: isRound ? '100%' : '0' }\"\r\n  >\r\n    <mc-avatar-body-icon [width]=\"width\" [height]=\"height\" />\r\n  </span>\r\n  <span\r\n    *ngIf=\"(!imgSrc && isNobody) || (imgSrc && isErrorImg)\"\r\n    class=\"mc-bubble-avatar-style\"\r\n    [ngStyle]=\"{ borderRadius: isRound ? '100%' : '0' }\"\r\n  >\r\n    <mc-avatar-no-body-icon [width]=\"width\" [height]=\"height\" />\r\n  </span>\r\n</span>", styles: [".mc-bubble-avatar-wrapper{display:inline-block}.mc-bubble-avatar-wrapper .mc-bubble-avatar-style{display:inline-block;text-align:center;color:var(--devui-light-text, #ffffff)}.mc-bubble-avatar-wrapper .mc-bubble-avatar-background-0{background-color:#ff8b87}.mc-bubble-avatar-wrapper .mc-bubble-avatar-background-1{background-color:#7693f5}\n"] }]
        }], propDecorators: { imgSrc: [{
                type: Input
            }], name: [{
                type: Input
            }], width: [{
                type: Input
            }], height: [{
                type: Input
            }], isRound: [{
                type: Input
            }], gender: [{
                type: Input
            }] } });

const DEFAULT_AVATAR_WIDTH = 36;
const DEFAULT_AVATAR_HEIGHT = 36;
const AVATAR_NAME = 'name';
const AVATAR_IMG = 'imgSrc';

const noop = () => { };
class BaseFoundation {
    static get cssClasses() {
        return {};
    }
    static get strings() {
        return {};
    }
    static get numbers() {
        return {};
    }
    static get defaultAdapter() {
        return {
            getProp: noop,
            getProps: noop,
            getState: noop,
            getStates: noop,
            setState: noop,
            getContext: noop,
            getContexts: noop,
            getCache: noop,
            setCache: noop,
            getCaches: noop,
            stopPropagation: noop,
        };
    }
    constructor(adapter) {
        this._adapter = { ...BaseFoundation.defaultAdapter, ...adapter };
    }
    getProp(key) {
        return this._adapter.getProp(key);
    }
    getProps() {
        return this._adapter.getProps();
    }
    getState(key) {
        return this._adapter.getState(key);
    }
    getStates() {
        return this._adapter.getStates();
    }
    setState(states, cb) {
        return this._adapter.setState({ ...states }, cb);
    }
    /* istanbul ignore next */
    getCaches() {
        return this._adapter.getCaches();
    }
    getCache(key) {
        return this._adapter.getCache(key);
    }
    setCache(key, value) {
        return key && this._adapter.setCache(key, value);
    }
    nextTick(cb) {
        return this._adapter.nextTick(cb);
    }
    _isInProps(key) {
        const props = this.getProps();
        return key in props;
    }
    init(lifecycle) { }
    destroy() { }
}

class BubbleFoundation extends BaseFoundation {
    constructor(adapter) {
        super({ ...adapter });
    }
    getBubbleClasses() {
        const { align, loading, isEmptyAvatar, avatarPosition } = this.getProps();
        return [
            `mc-bubble-avatar-${avatarPosition}`,
            `mc-bubble-${align}`,
            loading ? "mc-bubble-loading" : "",
            isEmptyAvatar ? "mc-bubble-avatar-empty" : "",
        ]
            .filter(Boolean)
            .join(" ");
    }
    getIsEmptyAvatar(avatarConfig) {
        if (avatarConfig) {
            // 传了 avatarConfig，但是没有 name 和 imgSrc 时表示头像区域仅占位
            const keys = Object.keys(avatarConfig);
            const shouldShow = keys.some((k) => k === AVATAR_NAME || k === AVATAR_IMG);
            return keys.length < 1 || !shouldShow;
        }
        else {
            return true;
        }
    }
}

class BaseComponent {
    constructor() {
    }
    ngOnDestroy() {
        this.foundation &&
            typeof this.foundation.destroy === 'function' &&
            this.foundation.destroy();
    }
    get adapter() {
        return {
            getProp: (key) => {
                return this[key];
            },
            getProps: () => {
                return this;
            },
            setState: (states, cb) => {
                for (const key in states) {
                    if (states.hasOwnProperty(key)) {
                        this[key] = states[key];
                    }
                    cb && cb();
                }
            },
            getState: (key) => this[key],
            getStates: () => this,
            getCache: (key) => key && this.cache[key],
            getCaches: () => this.cache,
            setCache: (key, value) => key && (this.cache[key] = value),
            nextTick: (cb) => setTimeout(cb, 0),
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: BaseComponent, isStandalone: true, selector: "mate-base-component", ngImport: i0, template: '', isInline: true }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BaseComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'mate-base-component',
                    standalone: true,
                    template: '',
                }]
        }], ctorParameters: () => [] });

class BubbleComponent extends BaseComponent {
    // 计算是否有内容投影
    get ngContentProjected() {
        return this.contentChildren && this.contentChildren.length > 0;
    }
    constructor() {
        super();
        // 组件属性
        this.content = '';
        this.loading = false;
        this.align = 'left';
        this.avatarPosition = 'side';
        this.variant = 'filled';
        // 内容投影模板引用
        this.avatarTemplate = null;
        this.topTemplate = null;
        this.loadingTplTemplate = null;
        this.bottomTemplate = null;
    }
    ngOnInit() {
        this.foundation = new BubbleFoundation(this.adapter);
        this.foundation.init();
    }
    get adapter() {
        return {
            ...super.adapter,
            getProps: () => ({
                content: this.content,
                loading: this.loading,
                align: this.align,
                avatarPosition: this.avatarPosition,
                variant: this.variant,
                avatarConfig: this.avatarConfig,
            }),
        };
    }
    // 计算属性
    get bubbleClasses() {
        return this.foundation.getBubbleClasses();
    }
    ;
    get isEmptyAvatar() {
        return this.foundation.getIsEmptyAvatar(this.avatarConfig);
    }
    ;
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: BubbleComponent, isStandalone: true, selector: "mc-bubble", inputs: { content: "content", loading: "loading", align: "align", avatarPosition: "avatarPosition", variant: "variant", avatarConfig: "avatarConfig" }, queries: [{ propertyName: "avatarTemplate", first: true, predicate: ["avatar"], descendants: true }, { propertyName: "topTemplate", first: true, predicate: ["top"], descendants: true }, { propertyName: "loadingTplTemplate", first: true, predicate: ["loadingTpl"], descendants: true }, { propertyName: "bottomTemplate", first: true, predicate: ["bottom"], descendants: true }, { propertyName: "contentChildren", predicate: ["ng-content"] }], usesInheritance: true, ngImport: i0, template: "<div class=\"mc-bubble\" [ngClass]=\"bubbleClasses\" role=\"group\" [attr.aria-label]=\"'Bubble.ariaLabel' | translate\">\r\n  <!-- \u81EA\u5B9A\u4E49\u5934\u50CF\u533A\u57DF -->\r\n  <div *ngIf=\"avatarTemplate\" class=\"mc-bubble-avatar\" role=\"img\">\r\n    <ng-container *ngTemplateOutlet=\"avatarTemplate\"></ng-container>\r\n    <ng-content select=\"[avatar]\"></ng-content>\r\n  </div>\r\n  \r\n  <!-- \u9ED8\u8BA4\u5934\u50CF\u914D\u7F6E -->\r\n  <div *ngIf=\"!avatarTemplate && avatarConfig\"\r\n    class=\"mc-bubble-avatar\" role=\"img\"\r\n    [ngClass]=\"{ 'empty-avatar': isEmptyAvatar }\"\r\n  >\r\n    <mc-avatar\r\n      *ngIf=\"!isEmptyAvatar\"\r\n      [imgSrc]=\"avatarConfig?.imgSrc || ''\"\r\n      [name]=\"avatarConfig?.name || ''\"\r\n      [width]=\"avatarConfig?.width || 36\"\r\n      [height]=\"avatarConfig?.height || 36\"\r\n      [gender]=\"avatarConfig?.gender || ''\"\r\n    />\r\n    <div *ngIf=\"isEmptyAvatar\"    class=\"mc-bubble-avatar-wrapper\" [attr.aria-label]=\"'Bubble.emptyAvatar' | translate\"\r\n         [style.width.px]=\"avatarConfig?.width || 36\"\r\n         [style.height.px]=\"avatarConfig?.height || 36\"></div>\r\n    <span *ngIf=\"avatarPosition === 'top'\" class=\"mc-bubble-avatar-name\" [attr.aria-label]=\"'Bubble.userName' | translate:{ name: avatarConfig?.displayName || '' } \">{{\r\n      avatarConfig?.displayName\r\n    }}</span>\r\n  </div>\r\n  <div\r\n    class=\"mc-bubble-content-container\" aria-live=\"polite\"\r\n    [ngClass]=\"{ 'with-avatar': avatarTemplate || avatarConfig }\"\r\n  >\r\n    <!-- \u9876\u90E8\u5185\u5BB9\u6295\u5F71 -->\r\n    <ng-container *ngIf=\"!loading\">\r\n      <ng-container *ngTemplateOutlet=\"topTemplate\"></ng-container>\r\n      <ng-content select=\"[top]\"></ng-content>\r\n    </ng-container>\r\n    \r\n    <!-- \u52A0\u8F7D\u72B6\u6001 -->\r\n    <div *ngIf=\"loading\" class=\"loading-container\" role=\"status\" aria-busy=\"true\">\r\n      <ng-container *ngIf=\"loadingTplTemplate; else defaultLoadingTemplate\">\r\n        <ng-container *ngTemplateOutlet=\"loadingTplTemplate\"></ng-container>\r\n        <ng-content select=\"[loadingTpl]\"></ng-content>\r\n      </ng-container>\r\n      <ng-template #defaultLoadingTemplate>\r\n        <mc-bubble-loading></mc-bubble-loading>\r\n      </ng-template>\r\n    </div>\r\n    \r\n    <!-- \u4E3B\u8981\u5185\u5BB9 -->\r\n    <div\r\n      *ngIf=\"!loading\"\r\n      class=\"mc-bubble-content\"\r\n      [ngClass]=\"[variant]\"\r\n      role=\"region\"\r\n    >\r\n      <ng-content></ng-content>\r\n      <ng-container *ngIf=\"content && !ngContentProjected\">\r\n        <span [attr.aria-label]=\"'Bubble.content' | translate\">{{ content }}</span>\r\n      </ng-container>\r\n    </div>\r\n    \r\n    <!-- \u5E95\u90E8\u5185\u5BB9\u6295\u5F71 -->\r\n    <ng-container *ngIf=\"!loading\">\r\n      <ng-container *ngTemplateOutlet=\"bottomTemplate\"></ng-container>\r\n      <ng-content select=\"[bottom]\"></ng-content>\r\n    </ng-container>\r\n  </div>\r\n</div>\r\n", styles: [".mc-bubble{display:flex;gap:4px;font-size:var(--devui-font-size, 14px)}.mc-bubble .mc-bubble-content{word-wrap:break-word}.mc-bubble .mc-bubble-content.filled,.mc-bubble .mc-bubble-content.bordered{padding:12px 16px;border-radius:12px}.mc-bubble .mc-bubble-content.filled{background-color:var(--devui-global-bg, #f6f6f8)}.mc-bubble .mc-bubble-content.bordered{border:1px solid var(--devui-dividing-line, #f2f2f3)}.mc-bubble .mc-bubble-avatar{flex-shrink:0;display:flex;gap:4px}.mc-bubble .mc-bubble-avatar .mc-bubble-avatar-name{font-size:14px}.mc-bubble .mc-bubble-avatar.empty-avatar{visibility:hidden}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar{align-items:center}.mc-bubble .mc-bubble-content-container{max-width:100%}.mc-bubble.mc-bubble-avatar-top{flex-direction:column}.mc-bubble.mc-bubble-avatar-top .mc-bubble-content-container{align-items:flex-start;flex-direction:column}.mc-bubble.mc-bubble-loading.mc-bubble-avatar-side{align-items:center}.mc-bubble.mc-bubble-avatar-side.mc-bubble-right{flex-direction:row-reverse;justify-content:end}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar,.mc-bubble.mc-bubble-avatar-top .mc-bubble-content-container{display:flex}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar,.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-content-container{align-items:flex-end}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar{flex-direction:row-reverse}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: BubbleLoadingComponent, selector: "mc-bubble-loading" }, { kind: "component", type: AvatarComponent, selector: "mc-avatar", inputs: ["imgSrc", "name", "width", "height", "isRound", "gender"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-bubble', standalone: true, imports: [CommonModule, BubbleLoadingComponent, AvatarComponent, TranslatePipe], template: "<div class=\"mc-bubble\" [ngClass]=\"bubbleClasses\" role=\"group\" [attr.aria-label]=\"'Bubble.ariaLabel' | translate\">\r\n  <!-- \u81EA\u5B9A\u4E49\u5934\u50CF\u533A\u57DF -->\r\n  <div *ngIf=\"avatarTemplate\" class=\"mc-bubble-avatar\" role=\"img\">\r\n    <ng-container *ngTemplateOutlet=\"avatarTemplate\"></ng-container>\r\n    <ng-content select=\"[avatar]\"></ng-content>\r\n  </div>\r\n  \r\n  <!-- \u9ED8\u8BA4\u5934\u50CF\u914D\u7F6E -->\r\n  <div *ngIf=\"!avatarTemplate && avatarConfig\"\r\n    class=\"mc-bubble-avatar\" role=\"img\"\r\n    [ngClass]=\"{ 'empty-avatar': isEmptyAvatar }\"\r\n  >\r\n    <mc-avatar\r\n      *ngIf=\"!isEmptyAvatar\"\r\n      [imgSrc]=\"avatarConfig?.imgSrc || ''\"\r\n      [name]=\"avatarConfig?.name || ''\"\r\n      [width]=\"avatarConfig?.width || 36\"\r\n      [height]=\"avatarConfig?.height || 36\"\r\n      [gender]=\"avatarConfig?.gender || ''\"\r\n    />\r\n    <div *ngIf=\"isEmptyAvatar\"    class=\"mc-bubble-avatar-wrapper\" [attr.aria-label]=\"'Bubble.emptyAvatar' | translate\"\r\n         [style.width.px]=\"avatarConfig?.width || 36\"\r\n         [style.height.px]=\"avatarConfig?.height || 36\"></div>\r\n    <span *ngIf=\"avatarPosition === 'top'\" class=\"mc-bubble-avatar-name\" [attr.aria-label]=\"'Bubble.userName' | translate:{ name: avatarConfig?.displayName || '' } \">{{\r\n      avatarConfig?.displayName\r\n    }}</span>\r\n  </div>\r\n  <div\r\n    class=\"mc-bubble-content-container\" aria-live=\"polite\"\r\n    [ngClass]=\"{ 'with-avatar': avatarTemplate || avatarConfig }\"\r\n  >\r\n    <!-- \u9876\u90E8\u5185\u5BB9\u6295\u5F71 -->\r\n    <ng-container *ngIf=\"!loading\">\r\n      <ng-container *ngTemplateOutlet=\"topTemplate\"></ng-container>\r\n      <ng-content select=\"[top]\"></ng-content>\r\n    </ng-container>\r\n    \r\n    <!-- \u52A0\u8F7D\u72B6\u6001 -->\r\n    <div *ngIf=\"loading\" class=\"loading-container\" role=\"status\" aria-busy=\"true\">\r\n      <ng-container *ngIf=\"loadingTplTemplate; else defaultLoadingTemplate\">\r\n        <ng-container *ngTemplateOutlet=\"loadingTplTemplate\"></ng-container>\r\n        <ng-content select=\"[loadingTpl]\"></ng-content>\r\n      </ng-container>\r\n      <ng-template #defaultLoadingTemplate>\r\n        <mc-bubble-loading></mc-bubble-loading>\r\n      </ng-template>\r\n    </div>\r\n    \r\n    <!-- \u4E3B\u8981\u5185\u5BB9 -->\r\n    <div\r\n      *ngIf=\"!loading\"\r\n      class=\"mc-bubble-content\"\r\n      [ngClass]=\"[variant]\"\r\n      role=\"region\"\r\n    >\r\n      <ng-content></ng-content>\r\n      <ng-container *ngIf=\"content && !ngContentProjected\">\r\n        <span [attr.aria-label]=\"'Bubble.content' | translate\">{{ content }}</span>\r\n      </ng-container>\r\n    </div>\r\n    \r\n    <!-- \u5E95\u90E8\u5185\u5BB9\u6295\u5F71 -->\r\n    <ng-container *ngIf=\"!loading\">\r\n      <ng-container *ngTemplateOutlet=\"bottomTemplate\"></ng-container>\r\n      <ng-content select=\"[bottom]\"></ng-content>\r\n    </ng-container>\r\n  </div>\r\n</div>\r\n", styles: [".mc-bubble{display:flex;gap:4px;font-size:var(--devui-font-size, 14px)}.mc-bubble .mc-bubble-content{word-wrap:break-word}.mc-bubble .mc-bubble-content.filled,.mc-bubble .mc-bubble-content.bordered{padding:12px 16px;border-radius:12px}.mc-bubble .mc-bubble-content.filled{background-color:var(--devui-global-bg, #f6f6f8)}.mc-bubble .mc-bubble-content.bordered{border:1px solid var(--devui-dividing-line, #f2f2f3)}.mc-bubble .mc-bubble-avatar{flex-shrink:0;display:flex;gap:4px}.mc-bubble .mc-bubble-avatar .mc-bubble-avatar-name{font-size:14px}.mc-bubble .mc-bubble-avatar.empty-avatar{visibility:hidden}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar{align-items:center}.mc-bubble .mc-bubble-content-container{max-width:100%}.mc-bubble.mc-bubble-avatar-top{flex-direction:column}.mc-bubble.mc-bubble-avatar-top .mc-bubble-content-container{align-items:flex-start;flex-direction:column}.mc-bubble.mc-bubble-loading.mc-bubble-avatar-side{align-items:center}.mc-bubble.mc-bubble-avatar-side.mc-bubble-right{flex-direction:row-reverse;justify-content:end}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar,.mc-bubble.mc-bubble-avatar-top .mc-bubble-content-container{display:flex}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar,.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-content-container{align-items:flex-end}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar{flex-direction:row-reverse}\n"] }]
        }], ctorParameters: () => [], propDecorators: { content: [{
                type: Input
            }], loading: [{
                type: Input
            }], align: [{
                type: Input
            }], avatarPosition: [{
                type: Input
            }], variant: [{
                type: Input
            }], avatarConfig: [{
                type: Input
            }], avatarTemplate: [{
                type: ContentChild,
                args: ['avatar']
            }], topTemplate: [{
                type: ContentChild,
                args: ['top']
            }], loadingTplTemplate: [{
                type: ContentChild,
                args: ['loadingTpl']
            }], bottomTemplate: [{
                type: ContentChild,
                args: ['bottom']
            }], contentChildren: [{
                type: ContentChildren,
                args: ['ng-content']
            }] } });

class BubbleModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.10", ngImport: i0, type: BubbleModule, imports: [CommonModule,
            BubbleComponent,
            BubbleLoadingComponent,
            AvatarComponent], exports: [BubbleComponent,
            BubbleLoadingComponent,
            AvatarComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleModule, imports: [CommonModule,
            BubbleComponent,
            AvatarComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BubbleModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [],
                    imports: [
                        CommonModule,
                        BubbleComponent,
                        BubbleLoadingComponent,
                        AvatarComponent
                    ],
                    exports: [
                        BubbleComponent,
                        BubbleLoadingComponent,
                        AvatarComponent
                    ]
                }]
        }] });

class SendIconComponent {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: SendIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: SendIconComponent, isStandalone: true, selector: "mc-send-icon", ngImport: i0, template: "<svg\r\n  width=\"16px\"\r\n  height=\"16px\"\r\n  viewBox=\"0 0 16 16\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <path\r\n      d=\"M13.5105149,2.56164948 C14.1211149,2.35546948 14.7829149,2.68328948 14.9892149,3.29376948 C15.0349149,3.42925948 15.0552149,3.57159948 15.0495149,3.71368948 L15.0495149,3.71368948 L15.0351149,3.85546948 L13.6575149,12.2717195 C13.5237149,13.0892195 12.7524149,13.6435195 11.9348149,13.5097195 C11.8542149,13.4965195 11.7751149,13.4768195 11.6980149,13.4508195 L11.6980149,13.4508195 L11.5840149,13.4071195 L9.3049349,12.4260195 L8.4482449,13.5422195 C8.1958049,13.8708195 7.8205549,14.0786195 7.4128449,14.1207195 L7.4128449,14.1207195 L7.2585449,14.1286195 C6.4787649,14.1286195 5.8381349,13.5337195 5.7653849,12.7731195 L5.7653849,12.7731195 L5.7585449,12.6286195 L5.7602549,10.5258195 L5.7756349,10.4384195 L5.7944349,10.3824195 L5.8266649,10.3168995 L5.8735349,10.2503695 L5.9177249,10.2039195 L12.6909149,3.89392948 L2.3403349,7.38903948 C2.2329149,7.42529948 2.1418449,7.49676948 2.0808149,7.59063948 L2.0808149,7.59063948 L2.0412649,7.66497948 C1.9440949,7.89044948 2.0258749,8.14788948 2.2236349,8.27917948 L2.2236349,8.27917948 L2.3029749,8.32214948 L4.4799849,9.26177948 C4.7333949,9.37121948 4.8503449,9.66546948 4.7409649,9.91894948 C4.6435549,10.1443495 4.4003949,10.2616595 4.1694349,10.2081295 L4.1694349,10.2081295 L4.0837449,10.1798795 L1.9072249,9.24047948 C1.1462449,8.91284948 0.795166898,8.03039948 1.1225549,7.26953948 C1.2700249,6.92755948 1.5380849,6.65435948 1.8730449,6.50018948 L1.8730449,6.50018948 L2.0205049,6.44158948 Z M6.7578149,11.3299195 L6.7585449,12.6286195 L6.7666013,12.7185103 C6.80894095,12.9517898 7.0131049,13.1286195 7.2585449,13.1286195 C7.3828149,13.1286195 7.5014649,13.0824195 7.5925349,13.0008195 L7.5925349,13.0008195 L7.6550349,12.9332195 L8.3569349,12.0179195 L6.7578149,11.3299195 Z M13.9888149,4.05090948 L7.1599149,10.4129195 L11.9795149,12.4886195 C11.9980149,12.4966195 12.0173149,12.5035195 12.0369149,12.5093195 L12.0369149,12.5093195 L12.0964149,12.5228195 C12.3386149,12.5624195 12.5686149,12.4209195 12.6482149,12.1975195 L12.6482149,12.1975195 L12.6706149,12.1101195 L13.9888149,4.05090948 Z\"\r\n    ></path>\r\n  </g>\r\n</svg>\r\n", styles: [":host{display:contents}:host svg{margin-right:4px}\n"] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: SendIconComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-send-icon', standalone: true, template: "<svg\r\n  width=\"16px\"\r\n  height=\"16px\"\r\n  viewBox=\"0 0 16 16\"\r\n  version=\"1.1\"\r\n  xmlns=\"http://www.w3.org/2000/svg\"\r\n>\r\n  <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n    <path\r\n      d=\"M13.5105149,2.56164948 C14.1211149,2.35546948 14.7829149,2.68328948 14.9892149,3.29376948 C15.0349149,3.42925948 15.0552149,3.57159948 15.0495149,3.71368948 L15.0495149,3.71368948 L15.0351149,3.85546948 L13.6575149,12.2717195 C13.5237149,13.0892195 12.7524149,13.6435195 11.9348149,13.5097195 C11.8542149,13.4965195 11.7751149,13.4768195 11.6980149,13.4508195 L11.6980149,13.4508195 L11.5840149,13.4071195 L9.3049349,12.4260195 L8.4482449,13.5422195 C8.1958049,13.8708195 7.8205549,14.0786195 7.4128449,14.1207195 L7.4128449,14.1207195 L7.2585449,14.1286195 C6.4787649,14.1286195 5.8381349,13.5337195 5.7653849,12.7731195 L5.7653849,12.7731195 L5.7585449,12.6286195 L5.7602549,10.5258195 L5.7756349,10.4384195 L5.7944349,10.3824195 L5.8266649,10.3168995 L5.8735349,10.2503695 L5.9177249,10.2039195 L12.6909149,3.89392948 L2.3403349,7.38903948 C2.2329149,7.42529948 2.1418449,7.49676948 2.0808149,7.59063948 L2.0808149,7.59063948 L2.0412649,7.66497948 C1.9440949,7.89044948 2.0258749,8.14788948 2.2236349,8.27917948 L2.2236349,8.27917948 L2.3029749,8.32214948 L4.4799849,9.26177948 C4.7333949,9.37121948 4.8503449,9.66546948 4.7409649,9.91894948 C4.6435549,10.1443495 4.4003949,10.2616595 4.1694349,10.2081295 L4.1694349,10.2081295 L4.0837449,10.1798795 L1.9072249,9.24047948 C1.1462449,8.91284948 0.795166898,8.03039948 1.1225549,7.26953948 C1.2700249,6.92755948 1.5380849,6.65435948 1.8730449,6.50018948 L1.8730449,6.50018948 L2.0205049,6.44158948 Z M6.7578149,11.3299195 L6.7585449,12.6286195 L6.7666013,12.7185103 C6.80894095,12.9517898 7.0131049,13.1286195 7.2585449,13.1286195 C7.3828149,13.1286195 7.5014649,13.0824195 7.5925349,13.0008195 L7.5925349,13.0008195 L7.6550349,12.9332195 L8.3569349,12.0179195 L6.7578149,11.3299195 Z M13.9888149,4.05090948 L7.1599149,10.4129195 L11.9795149,12.4886195 C11.9980149,12.4966195 12.0173149,12.5035195 12.0369149,12.5093195 L12.0369149,12.5093195 L12.0964149,12.5228195 C12.3386149,12.5624195 12.5686149,12.4209195 12.6482149,12.1975195 L12.6482149,12.1975195 L12.6706149,12.1101195 L13.9888149,4.05090948 Z\"\r\n    ></path>\r\n  </g>\r\n</svg>\r\n", styles: [":host{display:contents}:host svg{margin-right:4px}\n"] }]
        }] });

var DisplayType;
(function (DisplayType) {
    DisplayType["Simple"] = "simple";
    DisplayType["Full"] = "full";
})(DisplayType || (DisplayType = {}));
var InputVariant;
(function (InputVariant) {
    InputVariant["Bordered"] = "bordered";
    InputVariant["BorderLess"] = "borderless";
})(InputVariant || (InputVariant = {}));
var SendBtnVariant;
(function (SendBtnVariant) {
    SendBtnVariant["Simple"] = "simple";
    SendBtnVariant["Full"] = "full";
})(SendBtnVariant || (SendBtnVariant = {}));
var SubmitShortKey;
(function (SubmitShortKey) {
    SubmitShortKey["Enter"] = "enter";
    SubmitShortKey["ShiftEnter"] = "shiftEnter";
})(SubmitShortKey || (SubmitShortKey = {}));

class LocaleModule {
    /**
     * 静态方法，用于配置模块并提供服务
     * 可以在AppModule中使用LocaleModule.forRoot()来初始化
     */
    static forRoot() {
        return {
            ngModule: LocaleModule,
            providers: [
                LocaleService
            ]
        };
    }
    /**
     * 普通导入方法，用于特性模块中导入
     * 避免服务被多次实例化
     */
    static forChild() {
        return {
            ngModule: LocaleModule,
            providers: [] // 子模块不提供服务实例
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.10", ngImport: i0, type: LocaleModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: LocaleModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [],
                    imports: [],
                    exports: []
                }]
        }] });

// 导出Locale服务

class InputButtonFoundation extends BaseFoundation {
    constructor(adapter) {
        super({ ...adapter });
    }
    showClickWave(nativeElement, event) {
        const rect = nativeElement.getBoundingClientRect();
        this.setState({
            waveStyle: {
                left: event.clientX - rect.left + 'px',
                top: event.clientY - rect.top + 'px',
            },
            showWave: true,
        });
        setTimeout(() => {
            this.setState({
                showWave: false,
            });
        }, 300);
    }
    getButtonClasses() {
        const { loading, sendBtnVariant } = this.getProps();
        const isMouseDown = this.getState('isMouseDown');
        return {
            'mc-button': true,
            'mc-button-loading': loading,
            mousedown: isMouseDown,
            'mc-button-simple': sendBtnVariant === SendBtnVariant.Simple,
        };
    }
}

class ButtonComponent extends BaseComponent {
    constructor(localeService) {
        super();
        this.localeService = localeService;
        this.disabled = false;
        this.loading = false;
        this.inputValue = '';
        this.sendBtnVariant = SendBtnVariant.Full;
        this.submit = new EventEmitter();
        this.cancel = new EventEmitter();
        this.change = new EventEmitter();
        this.isMouseDown = false;
        this.showWave = false;
        this.waveStyle = { top: '0px', left: '0px' };
    }
    get buttonClasses() {
        return this.foundation.getButtonClasses();
    }
    ngOnInit() {
        this.foundation = new InputButtonFoundation(this.adapter);
        this.foundation.init();
    }
    onMouseDown() {
        this.isMouseDown = true;
    }
    onMouseUp() {
        this.isMouseDown = false;
    }
    showClickWave(event) {
        this.foundation.showClickWave(this.buttonElement.nativeElement, event);
    }
    onConfirm(event) {
        this.showClickWave(event);
        if (this.loading) {
            this.cancel.emit();
        }
        else {
            this.submit.emit(this.inputValue);
            this.inputValue = '';
            this.change.emit(this.inputValue);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: ButtonComponent, deps: [{ token: LocaleService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: ButtonComponent, isStandalone: true, selector: "mc-button", inputs: { disabled: "disabled", loading: "loading", inputValue: "inputValue", sendBtnVariant: "sendBtnVariant" }, outputs: { submit: "submit", cancel: "cancel", change: "change" }, host: { listeners: { "mousedown": "onMouseDown()", "mouseup": "onMouseUp()" } }, viewQueries: [{ propertyName: "buttonElement", first: true, predicate: ["button"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<button\r\n  #button\r\n  [disabled]=\"disabled || (!loading && !inputValue)\"\r\n  [ngClass]=\"buttonClasses\"\r\n  (click)=\"onConfirm($event)\"\r\n  [attr.aria-label]=\"loading ? ('Input.pauseAnswer' | translate) : ('Input.send' | translate)\"\r\n  [attr.aria-disabled]=\"disabled || (!loading && !inputValue)\"\r\n  [attr.aria-busy]=\"loading\"\r\n>\r\n  <span class=\"mc-button-content\">\r\n    <ng-container *ngIf=\"loading\">\r\n      <ng-template [ngTemplateOutlet]=\"loadingIcon\"></ng-template>\r\n    </ng-container>\r\n    <mc-send-icon *ngIf=\"!loading\"></mc-send-icon>\r\n    <span *ngIf=\"sendBtnVariant === 'full'\">\r\n      {{\r\n        loading ? (\"Input.pauseAnswer\" | translate) : (\"Input.send\" | translate)\r\n      }}\r\n    </span>\r\n  </span>\r\n  <div\r\n    *ngIf=\"showWave\"\r\n    class=\"mc-button-water-wave\"\r\n    [style.top]=\"waveStyle.top\"\r\n    [style.left]=\"waveStyle.left\"\r\n  ></div>\r\n</button>\r\n\r\n<ng-template #loadingIcon>\r\n  <svg\r\n    width=\"16px\"\r\n    height=\"16px\"\r\n    viewBox=\"0 0 16 16\"\r\n    version=\"1.1\"\r\n    xmlns=\"http://www.w3.org/2000/svg\"\r\n  >\r\n    <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n      <path\r\n        d=\"M8,12 C8.27614237,12 8.5,12.2238576 8.5,12.5 L8.5,14.5 C8.5,14.7761424 8.27614237,15 8,15 C7.72385763,15 7.5,14.7761424 7.5,14.5 L7.5,12.5 C7.5,12.2238576 7.72385763,12 8,12 Z M11.0495421,11.3466838 L12.2251126,12.9647178 C12.3874251,13.1881217 12.3379006,13.5008065 12.1144968,13.663119 C11.8910929,13.8254314 11.5784081,13.775907 11.4160956,13.5525031 L10.2405251,11.9344691 C10.0782127,11.7110652 10.1277371,11.3983804 10.351141,11.236068 C10.5745449,11.0737556 10.8872297,11.12328 11.0495421,11.3466838 Z M5.64885899,11.236068 C5.87226287,11.3983804 5.92178728,11.7110652 5.75947486,11.9344691 L4.58390436,13.5525031 C4.42159194,13.775907 4.10890711,13.8254314 3.88550323,13.663119 C3.66209936,13.5008065 3.61257495,13.1881217 3.77488736,12.9647178 L4.95045787,11.3466838 C5.11277028,11.12328 5.42545512,11.0737556 5.64885899,11.236068 Z M12.4342628,8.91504822 L14.3363759,9.53308221 C14.5990029,9.61841489 14.7427283,9.90049196 14.6573956,10.163119 C14.5720629,10.425746 14.2899859,10.5694714 14.0273589,10.4841387 L12.1252458,9.86610473 C11.8626188,9.78077205 11.7188934,9.49869498 11.8042261,9.23606798 C11.8895588,8.97344097 12.1716358,8.82971553 12.4342628,8.91504822 Z M4.19577393,9.23606798 C4.28110662,9.49869498 4.13738118,9.78077205 3.87475417,9.86610473 L1.97264114,10.4841387 C1.71001414,10.5694714 1.42793707,10.425746 1.34260439,10.163119 C1.2572717,9.90049196 1.40099714,9.61841489 1.66362415,9.53308221 L3.56573718,8.91504822 C3.82836418,8.82971553 4.11044125,8.97344097 4.19577393,9.23606798 Z M14.6573956,5.83688104 C14.7427283,6.09950804 14.5990029,6.38158511 14.3363759,6.46691779 L12.4342628,7.08495178 C12.1716358,7.17028447 11.8895588,7.02655903 11.8042261,6.76393202 C11.7188934,6.50130502 11.8626188,6.21922795 12.1252458,6.13389527 L14.0273589,5.51586128 C14.2899859,5.43052859 14.5720629,5.57425403 14.6573956,5.83688104 Z M1.97264114,5.51586128 L3.87475417,6.13389527 C4.13738118,6.21922795 4.28110662,6.50130502 4.19577393,6.76393202 C4.11044125,7.02655903 3.82836418,7.17028447 3.56573718,7.08495178 L1.66362415,6.46691779 C1.40099714,6.38158511 1.2572717,6.09950804 1.34260439,5.83688104 C1.42793707,5.57425403 1.71001414,5.43052859 1.97264114,5.51586128 Z M12.1144968,2.33688104 C12.3379006,2.49919345 12.3874251,2.81187829 12.2251126,3.03528216 L11.0495421,4.65331615 C10.8872297,4.87672003 10.5745449,4.92624444 10.351141,4.76393202 C10.1277371,4.60161961 10.0782127,4.28893477 10.2405251,4.0655309 L11.4160956,2.44749691 C11.5784081,2.22409304 11.8910929,2.17456862 12.1144968,2.33688104 Z M4.58390436,2.44749691 L5.75947486,4.0655309 C5.92178728,4.28893477 5.87226287,4.60161961 5.64885899,4.76393202 C5.42545512,4.92624444 5.11277028,4.87672003 4.95045787,4.65331615 L3.77488736,3.03528216 C3.61257495,2.81187829 3.66209936,2.49919345 3.88550323,2.33688104 C4.10890711,2.17456862 4.42159194,2.22409304 4.58390436,2.44749691 Z M8,1 C8.27614237,1 8.5,1.22385763 8.5,1.5 L8.5,3.5 C8.5,3.77614237 8.27614237,4 8,4 C7.72385763,4 7.5,3.77614237 7.5,3.5 L7.5,1.5 C7.5,1.22385763 7.72385763,1 8,1 Z\"\r\n      ></path>\r\n    </g>\r\n  </svg>\r\n</ng-template>\r\n", styles: [".mc-button{position:relative;display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;height:32px;line-height:1.5;color:var(--devui-light-text, #ffffff);font-size:var(--devui-font-size, 14px);padding:0 12px;border-radius:20px;background-color:var(--devui-primary, #5e7ce0);overflow:hidden;border:none;cursor:pointer;transition:background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.mc-button.mc-button-loading svg{animation:rotating 1s linear infinite}.mc-button.mousedown:not(:disabled){transform:scale(.95)}.mc-button.mc-button-simple{width:32px;padding:6px;flex-shrink:0;border-radius:100%}.mc-button.mc-button-simple svg{margin-right:0}.mc-button:hover{background-color:var(--devui-primary-hover, #7693f5)}.mc-button:active{background-color:var(--devui-primary-active, #344899)}.mc-button:disabled{color:var(--devui-light-text, #ffffff);background-color:var(--devui-primary-disabled, #beccfa);cursor:not-allowed}.mc-button .mc-button-content{display:inline-flex;align-items:center;font-size:var(--devui-font-size, 14px)}.mc-button .mc-button-water-wave{position:absolute;background-color:var(--devui-base-bg, #ffffff);border-radius:50%;opacity:0;width:20px;height:20px;transform:translate(-50%,-50%);animation:waterWave var(--devui-animation-duration-slow, .3s) var(--devui-animation-linear, cubic-bezier(0, 0, 1, 1))}.mc-button ::ng-deep svg{margin-right:4px}.mc-button ::ng-deep svg path{fill:var(--devui-light-text, #ffffff)}@keyframes rotating{0%{transform:rotate(0)}to{transform:rotate(180deg)}}@keyframes waterWave{0%{opacity:.2;width:30px;height:30px}to{opacity:0;width:200px;height:200px}}.mc-button-simple ::ng-deep svg{margin-right:0!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: SendIconComponent, selector: "mc-send-icon" }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: ButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-button', standalone: true, imports: [CommonModule, SendIconComponent, TranslatePipe], template: "<button\r\n  #button\r\n  [disabled]=\"disabled || (!loading && !inputValue)\"\r\n  [ngClass]=\"buttonClasses\"\r\n  (click)=\"onConfirm($event)\"\r\n  [attr.aria-label]=\"loading ? ('Input.pauseAnswer' | translate) : ('Input.send' | translate)\"\r\n  [attr.aria-disabled]=\"disabled || (!loading && !inputValue)\"\r\n  [attr.aria-busy]=\"loading\"\r\n>\r\n  <span class=\"mc-button-content\">\r\n    <ng-container *ngIf=\"loading\">\r\n      <ng-template [ngTemplateOutlet]=\"loadingIcon\"></ng-template>\r\n    </ng-container>\r\n    <mc-send-icon *ngIf=\"!loading\"></mc-send-icon>\r\n    <span *ngIf=\"sendBtnVariant === 'full'\">\r\n      {{\r\n        loading ? (\"Input.pauseAnswer\" | translate) : (\"Input.send\" | translate)\r\n      }}\r\n    </span>\r\n  </span>\r\n  <div\r\n    *ngIf=\"showWave\"\r\n    class=\"mc-button-water-wave\"\r\n    [style.top]=\"waveStyle.top\"\r\n    [style.left]=\"waveStyle.left\"\r\n  ></div>\r\n</button>\r\n\r\n<ng-template #loadingIcon>\r\n  <svg\r\n    width=\"16px\"\r\n    height=\"16px\"\r\n    viewBox=\"0 0 16 16\"\r\n    version=\"1.1\"\r\n    xmlns=\"http://www.w3.org/2000/svg\"\r\n  >\r\n    <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n      <path\r\n        d=\"M8,12 C8.27614237,12 8.5,12.2238576 8.5,12.5 L8.5,14.5 C8.5,14.7761424 8.27614237,15 8,15 C7.72385763,15 7.5,14.7761424 7.5,14.5 L7.5,12.5 C7.5,12.2238576 7.72385763,12 8,12 Z M11.0495421,11.3466838 L12.2251126,12.9647178 C12.3874251,13.1881217 12.3379006,13.5008065 12.1144968,13.663119 C11.8910929,13.8254314 11.5784081,13.775907 11.4160956,13.5525031 L10.2405251,11.9344691 C10.0782127,11.7110652 10.1277371,11.3983804 10.351141,11.236068 C10.5745449,11.0737556 10.8872297,11.12328 11.0495421,11.3466838 Z M5.64885899,11.236068 C5.87226287,11.3983804 5.92178728,11.7110652 5.75947486,11.9344691 L4.58390436,13.5525031 C4.42159194,13.775907 4.10890711,13.8254314 3.88550323,13.663119 C3.66209936,13.5008065 3.61257495,13.1881217 3.77488736,12.9647178 L4.95045787,11.3466838 C5.11277028,11.12328 5.42545512,11.0737556 5.64885899,11.236068 Z M12.4342628,8.91504822 L14.3363759,9.53308221 C14.5990029,9.61841489 14.7427283,9.90049196 14.6573956,10.163119 C14.5720629,10.425746 14.2899859,10.5694714 14.0273589,10.4841387 L12.1252458,9.86610473 C11.8626188,9.78077205 11.7188934,9.49869498 11.8042261,9.23606798 C11.8895588,8.97344097 12.1716358,8.82971553 12.4342628,8.91504822 Z M4.19577393,9.23606798 C4.28110662,9.49869498 4.13738118,9.78077205 3.87475417,9.86610473 L1.97264114,10.4841387 C1.71001414,10.5694714 1.42793707,10.425746 1.34260439,10.163119 C1.2572717,9.90049196 1.40099714,9.61841489 1.66362415,9.53308221 L3.56573718,8.91504822 C3.82836418,8.82971553 4.11044125,8.97344097 4.19577393,9.23606798 Z M14.6573956,5.83688104 C14.7427283,6.09950804 14.5990029,6.38158511 14.3363759,6.46691779 L12.4342628,7.08495178 C12.1716358,7.17028447 11.8895588,7.02655903 11.8042261,6.76393202 C11.7188934,6.50130502 11.8626188,6.21922795 12.1252458,6.13389527 L14.0273589,5.51586128 C14.2899859,5.43052859 14.5720629,5.57425403 14.6573956,5.83688104 Z M1.97264114,5.51586128 L3.87475417,6.13389527 C4.13738118,6.21922795 4.28110662,6.50130502 4.19577393,6.76393202 C4.11044125,7.02655903 3.82836418,7.17028447 3.56573718,7.08495178 L1.66362415,6.46691779 C1.40099714,6.38158511 1.2572717,6.09950804 1.34260439,5.83688104 C1.42793707,5.57425403 1.71001414,5.43052859 1.97264114,5.51586128 Z M12.1144968,2.33688104 C12.3379006,2.49919345 12.3874251,2.81187829 12.2251126,3.03528216 L11.0495421,4.65331615 C10.8872297,4.87672003 10.5745449,4.92624444 10.351141,4.76393202 C10.1277371,4.60161961 10.0782127,4.28893477 10.2405251,4.0655309 L11.4160956,2.44749691 C11.5784081,2.22409304 11.8910929,2.17456862 12.1144968,2.33688104 Z M4.58390436,2.44749691 L5.75947486,4.0655309 C5.92178728,4.28893477 5.87226287,4.60161961 5.64885899,4.76393202 C5.42545512,4.92624444 5.11277028,4.87672003 4.95045787,4.65331615 L3.77488736,3.03528216 C3.61257495,2.81187829 3.66209936,2.49919345 3.88550323,2.33688104 C4.10890711,2.17456862 4.42159194,2.22409304 4.58390436,2.44749691 Z M8,1 C8.27614237,1 8.5,1.22385763 8.5,1.5 L8.5,3.5 C8.5,3.77614237 8.27614237,4 8,4 C7.72385763,4 7.5,3.77614237 7.5,3.5 L7.5,1.5 C7.5,1.22385763 7.72385763,1 8,1 Z\"\r\n      ></path>\r\n    </g>\r\n  </svg>\r\n</ng-template>\r\n", styles: [".mc-button{position:relative;display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;height:32px;line-height:1.5;color:var(--devui-light-text, #ffffff);font-size:var(--devui-font-size, 14px);padding:0 12px;border-radius:20px;background-color:var(--devui-primary, #5e7ce0);overflow:hidden;border:none;cursor:pointer;transition:background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.mc-button.mc-button-loading svg{animation:rotating 1s linear infinite}.mc-button.mousedown:not(:disabled){transform:scale(.95)}.mc-button.mc-button-simple{width:32px;padding:6px;flex-shrink:0;border-radius:100%}.mc-button.mc-button-simple svg{margin-right:0}.mc-button:hover{background-color:var(--devui-primary-hover, #7693f5)}.mc-button:active{background-color:var(--devui-primary-active, #344899)}.mc-button:disabled{color:var(--devui-light-text, #ffffff);background-color:var(--devui-primary-disabled, #beccfa);cursor:not-allowed}.mc-button .mc-button-content{display:inline-flex;align-items:center;font-size:var(--devui-font-size, 14px)}.mc-button .mc-button-water-wave{position:absolute;background-color:var(--devui-base-bg, #ffffff);border-radius:50%;opacity:0;width:20px;height:20px;transform:translate(-50%,-50%);animation:waterWave var(--devui-animation-duration-slow, .3s) var(--devui-animation-linear, cubic-bezier(0, 0, 1, 1))}.mc-button ::ng-deep svg{margin-right:4px}.mc-button ::ng-deep svg path{fill:var(--devui-light-text, #ffffff)}@keyframes rotating{0%{transform:rotate(0)}to{transform:rotate(180deg)}}@keyframes waterWave{0%{opacity:.2;width:30px;height:30px}to{opacity:0;width:200px;height:200px}}.mc-button-simple ::ng-deep svg{margin-right:0!important}\n"] }]
        }], ctorParameters: () => [{ type: LocaleService }], propDecorators: { disabled: [{
                type: Input
            }], loading: [{
                type: Input
            }], inputValue: [{
                type: Input
            }], sendBtnVariant: [{
                type: Input
            }], submit: [{
                type: Output
            }], cancel: [{
                type: Output
            }], change: [{
                type: Output
            }], buttonElement: [{
                type: ViewChild,
                args: ['button']
            }], onMouseDown: [{
                type: HostListener,
                args: ['mousedown']
            }], onMouseUp: [{
                type: HostListener,
                args: ['mouseup']
            }] } });

class InputFoundation extends BaseFoundation {
    constructor(adapter) {
        super({ ...adapter });
    }
    getInputClasses() {
        const { disabled, displayType, variant } = this.getProps();
        return {
            'mc-input': true,
            'mc-input-disabled': disabled,
            'mc-input-simple': displayType === DisplayType.Simple,
            'mc-input-borderless': variant === InputVariant.BorderLess,
        };
    }
    getPlaceholderText() {
        const { placeholder, submitShortKey } = this.getProps();
        if (placeholder) {
            return placeholder;
        }
        let enterKey = '';
        let shiftEnterKey = '';
        if (submitShortKey === SubmitShortKey.Enter) {
            enterKey = 'Enter';
            shiftEnterKey = 'Shift + Enter';
        }
        else if (submitShortKey === SubmitShortKey.ShiftEnter) {
            enterKey = 'Shift + Enter';
            shiftEnterKey = 'Enter';
        }
        return enterKey
            ? this._adapter.locale('Input.pleaseEnterPlaceholder', {
                enterKey,
                shiftEnterKey,
            })
            : this._adapter.locale('Input.pleaseEnter');
    }
    clearInput() {
        this.setState({
            inputValue: '',
        });
        this._adapter.emitChange();
    }
    emitChange() {
        this._adapter.emitChange();
    }
    submit(inputValue) {
        this._adapter.submit(inputValue);
    }
    onKeydown(event) {
        const { submitShortKey, lock } = this.getProps();
        const inputValue = this.getState('inputValue');
        if (submitShortKey === null) {
            return;
        }
        const shiftKey = submitShortKey === SubmitShortKey.Enter
            ? !event.shiftKey
            : submitShortKey === SubmitShortKey.ShiftEnter
                ? event.shiftKey
                : false;
        if (shiftKey && event.key === 'Enter' && !lock) {
            event.preventDefault();
            this.submit(inputValue);
            this.setState({
                inputValue: '',
            });
            this.emitChange();
        }
    }
}

// 默认的autosize配置
const DEFAULT_AUTOSIZE = {
    minRows: 1,
    maxRows: 5
};
// 创建一个token用于组件间通信
const inputContextToken = 'input-context';
class InputComponent extends BaseComponent {
    constructor(localeService) {
        super();
        this.localeService = localeService;
        this.value = '';
        this.placeholder = '';
        this.disabled = false;
        this.displayType = DisplayType.Full;
        this.variant = InputVariant.Bordered;
        this.sendBtnVariant = SendBtnVariant.Full;
        this.loading = false;
        this.showCount = false;
        this.maxLength = null;
        this.submitShortKey = SubmitShortKey.Enter;
        this.autofocus = false;
        this.autosize = false;
        // textarea样式
        this.textareaStyle = {};
        this.change = new EventEmitter();
        this.submit = new EventEmitter();
        this.cancel = new EventEmitter();
        this.focus = new EventEmitter();
        this.blur = new EventEmitter();
        this.headTemplate = null;
        this.prefixTemplate = null;
        this.suffixTemplate = null;
        this.buttonTemplate = null;
        this.extraTemplate = null;
        this.inputValue = '';
        this.lock = false;
    }
    ngOnInit() {
        this.foundation = new InputFoundation(this.adapter);
        this.foundation.init();
        this.inputValue = this.value || '';
    }
    get adapter() {
        return {
            ...super.adapter,
            locale: (key, params) => this.localeService.translate(key, params),
            emitChange: () => {
                this.change.emit(this.inputValue);
            },
            submit: (inputValue) => {
                this.submit.emit(inputValue);
            },
        };
    }
    onChange(e) {
        e.stopPropagation();
        this.foundation.emitChange();
    }
    ngOnChanges(changes) {
        if (changes['value']) {
            this.inputValue = changes['value']?.currentValue || '';
            // 值变化时更新textarea样式
            this.updateTextareaStyle();
        }
        if (changes['autosize']) {
            // autosize配置变化时更新textarea样式
            this.updateTextareaStyle();
        }
    }
    get inputClasses() {
        return this.foundation.getInputClasses();
    }
    get maxlengthValue() {
        return this.maxLength !== undefined ? this.maxLength : null;
    }
    onInput() {
        if (!this.lock) {
            this.foundation.emitChange();
            // 输入时更新textarea样式
            this.updateTextareaStyle();
        }
    }
    onCompositionStart() {
        this.lock = true;
    }
    onCompositionEnd() {
        this.lock = false;
        this.foundation.emitChange();
    }
    onKeydown(event) {
        this.foundation.onKeydown(event);
    }
    clearInput() {
        this.foundation.clearInput();
    }
    getInput() {
        return this.inputValue;
    }
    // 处理button组件的事件
    onButtonSubmit(value) {
        this.submit.emit(value);
    }
    onButtonCancel() {
        this.cancel.emit();
    }
    onButtonChange(value) {
        this.inputValue = value;
        this.foundation.emitChange();
    }
    ngAfterViewInit() {
        if (this.autofocus && this.textareaElement && !this.disabled) {
            // 在下一个变更检测周期中聚焦，以确保视图已经完全初始化
            setTimeout(() => {
                this.textareaElement.nativeElement.focus();
            });
        }
        // 初始化时更新textarea样式
        this.updateTextareaStyle();
    }
    // 更新textarea样式
    updateTextareaStyle() {
        if (!this.textareaElement || this.autosize === false) {
            this.textareaStyle = {};
            return;
        }
        const config = this.getAutosizeConfig();
        const result = this.computeTextareaHeight(this.textareaElement.nativeElement, config.minRows, config.maxRows);
        this.textareaStyle = {
            ...result,
            resize: 'none'
        };
    }
    // 获取autosize配置
    getAutosizeConfig() {
        return typeof this.autosize === 'boolean'
            ? DEFAULT_AUTOSIZE
            : this.autosize;
    }
    // 计算textarea高度
    computeTextareaHeight(targetElement, minRows = 1, maxRows) {
        const style = window.getComputedStyle(targetElement);
        const boxSizing = style.getPropertyValue('box-sizing');
        const paddingSize = Number.parseFloat(style.getPropertyValue('padding-top')) +
            Number.parseFloat(style.getPropertyValue('padding-bottom'));
        const borderSize = Number.parseFloat(style.getPropertyValue('border-top-width')) +
            Number.parseFloat(style.getPropertyValue('border-bottom-width'));
        // 创建临时textarea元素
        const tempTextarea = document.createElement('textarea');
        const sizingStyle = [
            'letter-spacing', 'line-height', 'padding-top', 'padding-bottom',
            'font-family', 'font-weight', 'font-size', 'font-variant',
            'text-rendering', 'text-transform', 'width', 'text-indent',
            'padding-left', 'padding-right', 'border-width', 'box-sizing',
            'word-break', 'white-space'
        ];
        const contextStyle = sizingStyle
            .map(name => `${name}:${style.getPropertyValue(name)}`)
            .join(';');
        const hiddenStyle = `
      min-height:0 !important;
      max-height:none !important;
      height:0 !important;
      visibility:hidden !important;
      overflow:hidden !important;
      position:absolute !important;
      z-index:-1000 !important;
      top:0 !important;
      right:0 !important;
      pointer-events:none !important;
    `;
        tempTextarea.setAttribute('style', `${contextStyle};${hiddenStyle}`);
        tempTextarea.value = targetElement.value || targetElement.placeholder || '';
        document.body.appendChild(tempTextarea);
        let height = tempTextarea.scrollHeight;
        const result = {
            height: `${height}px`
        };
        if (minRows !== undefined || maxRows !== undefined) {
            tempTextarea.value = ' ';
            const singleRowHeight = tempTextarea.scrollHeight - paddingSize;
            if (minRows !== undefined) {
                let minHeight = singleRowHeight * minRows;
                if (boxSizing === 'border-box') {
                    minHeight = minHeight + paddingSize + borderSize;
                }
                height = Math.max(minHeight, height);
                result['minHeight'] = `${minHeight}px`;
            }
            if (maxRows !== undefined) {
                let maxHeight = singleRowHeight * maxRows;
                if (boxSizing === 'border-box') {
                    maxHeight = maxHeight + paddingSize + borderSize;
                }
                if (height > maxHeight) {
                    height = maxHeight;
                    result['overflowY'] = 'auto';
                }
            }
        }
        document.body.removeChild(tempTextarea);
        result['height'] = `${height}px`;
        return result;
    }
    get placeholderText() {
        return this.foundation.getPlaceholderText();
    }
    onFocus(event) {
        this.focus.emit(event);
    }
    onBlur(event) {
        this.blur.emit(event);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: InputComponent, deps: [{ token: LocaleService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: InputComponent, isStandalone: true, selector: "mc-input", inputs: { value: "value", placeholder: "placeholder", disabled: "disabled", displayType: "displayType", variant: "variant", sendBtnVariant: "sendBtnVariant", loading: "loading", showCount: "showCount", maxLength: "maxLength", submitShortKey: "submitShortKey", autofocus: "autofocus", autosize: "autosize" }, outputs: { change: "change", submit: "submit", cancel: "cancel", focus: "focus", blur: "blur" }, providers: [{ provide: inputContextToken, useExisting: InputComponent }], queries: [{ propertyName: "headTemplate", first: true, predicate: ["head"], descendants: true }, { propertyName: "prefixTemplate", first: true, predicate: ["prefix"], descendants: true }, { propertyName: "suffixTemplate", first: true, predicate: ["suffix"], descendants: true }, { propertyName: "buttonTemplate", first: true, predicate: ["button"], descendants: true }, { propertyName: "extraTemplate", first: true, predicate: ["extra"], descendants: true }], viewQueries: [{ propertyName: "textareaElement", first: true, predicate: ["textarea"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div [ngClass]=\"inputClasses\">\r\n  <ng-container *ngIf=\"headTemplate; then headTemplate\"></ng-container>\r\n\r\n  <div class=\"mc-input-content\">\r\n    <ng-container *ngIf=\"prefixTemplate; then prefixTemplate\"></ng-container>\r\n\r\n    <textarea\r\n      #textarea\r\n      [(ngModel)]=\"inputValue\"\r\n      [placeholder]=\"placeholderText\"\r\n      [disabled]=\"disabled\"\r\n      [maxlength]=\"maxLength\"\r\n      class=\"mc-textarea\"\r\n      [ngClass]=\"{\r\n        'mc-textarea-simple': displayType === 'simple',\r\n        'mc-textarea-disabled': disabled\r\n      }\"\r\n      [ngStyle]=\"textareaStyle\"\r\n      [attr.aria-label]=\"'Input.ariaLabel' | translate\"\r\n      [attr.aria-disabled]=\"disabled\"\r\n      (input)=\"onInput()\"\r\n      (change)=\"onChange($event)\"\r\n      (compositionstart)=\"onCompositionStart()\"\r\n      (compositionend)=\"onCompositionEnd()\"\r\n      (keydown)=\"onKeydown($event)\"\r\n      (focus)=\"onFocus($event)\"\r\n      (blur)=\"onBlur($event)\"\r\n    ></textarea>\r\n    <ng-container *ngIf=\"suffixTemplate; then suffixTemplate\"></ng-container>\r\n\r\n    <ng-container *ngIf=\"displayType === 'simple'\">\r\n      <ng-container *ngIf=\"buttonTemplate; else defaultButton\">\r\n        <ng-container\r\n          *ngIf=\"buttonTemplate; then buttonTemplate\"\r\n        ></ng-container>\r\n      </ng-container>\r\n      <ng-template #defaultButton>\r\n        <mc-button\r\n          [disabled]=\"disabled || (!loading && !inputValue)\"\r\n          [loading]=\"loading\"\r\n          [inputValue]=\"inputValue\"\r\n          [sendBtnVariant]=\"sendBtnVariant\"\r\n          (submit)=\"onButtonSubmit($event)\"\r\n          (cancel)=\"onButtonCancel()\"\r\n          (change)=\"onButtonChange($event)\"\r\n        ></mc-button>\r\n      </ng-template>\r\n    </ng-container>\r\n  </div>\r\n\r\n  <div *ngIf=\"displayType === 'full'\" class=\"mc-input-foot\">\r\n    <div class=\"mc-input-foot-left\">\r\n      <ng-container *ngIf=\"extraTemplate; then extraTemplate\"></ng-container>\r\n      <span *ngIf=\"showCount\" id=\"mc-input-count\" class=\"mc-input-foot-count\">\r\n        {{ inputValue.length }}{{ !maxLength ? \"\" : \"/\" + maxLength }}\r\n      </span>\r\n    </div>\r\n\r\n    <ng-container *ngIf=\"buttonTemplate; else defaultFooterButton\">\r\n      <ng-container *ngIf=\"buttonTemplate; then buttonTemplate\"></ng-container>\r\n    </ng-container>\r\n    <ng-template #defaultFooterButton>\r\n      <mc-button\r\n        [disabled]=\"disabled || (!loading && !inputValue)\"\r\n        [loading]=\"loading\"\r\n        [inputValue]=\"inputValue\"\r\n        [sendBtnVariant]=\"sendBtnVariant\"\r\n        (submit)=\"onButtonSubmit($event)\"\r\n        (cancel)=\"onButtonCancel()\"\r\n        (change)=\"onButtonChange($event)\"\r\n      ></mc-button>\r\n    </ng-template>\r\n  </div>\r\n</div>\r\n", styles: ["@charset \"UTF-8\";body[ui-theme=infinity-theme]{--mc-text: #aeaeae;--mc-box-shadow: rgba(25, 25, 25, .06)}body[ui-theme=galaxy-theme]{--mc-text: #4e5057;--mc-box-shadow: rgba(206, 209, 219, .06)}.mc-input{display:flex;flex-direction:column;width:100%;padding:12px 0;border:1px solid var(--devui-form-control-line, #d7d8da);border-radius:16px;box-sizing:border-box;background-color:var(--devui-base-bg, #ffffff)}.mc-input.mc-input-simple{border-radius:24px}.mc-input.mc-input-simple .mc-input-content{padding:0 20px}.mc-input.mc-input-borderless{border:none;box-shadow:0 1px 8px 0 var(--mc-box-shadow, rgba(25, 25, 25, .06))}.mc-input.mc-input-disabled{background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-input .mc-input-content{display:flex;align-items:flex-end;padding:0 16px}.mc-input .mc-input-foot{display:flex;justify-content:space-between;align-items:center;height:32px;padding:0 16px}.mc-input .mc-input-foot .mc-input-foot-left{flex:1;height:100%;display:flex;align-items:center}.mc-input .mc-input-foot .mc-input-foot-left .mc-input-foot-count{color:var(--mc-text, #aeaeae);font-size:var(--devui-font-size-sm, 12px)}.mc-textarea{width:100%;height:64px;padding:4px 0;color:var(--devui-text, #252b3a);font-size:var(--devui-font-size, 14px);background-color:var(--devui-form-control-bg, #ffffff);vertical-align:middle;outline:none;box-sizing:border-box;resize:none;border:none}.mc-textarea.mc-textarea-simple{height:32px}.mc-textarea.mc-textarea-disabled{color:var(--devui-disabled-text, #cfd0d3);background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-textarea::placeholder{color:var(--devui-placeholder, #babbc0)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ButtonComponent, selector: "mc-button", inputs: ["disabled", "loading", "inputValue", "sendBtnVariant"], outputs: ["submit", "cancel", "change"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: InputComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-input', standalone: true, imports: [CommonModule, FormsModule, ButtonComponent, TranslatePipe], providers: [{ provide: inputContextToken, useExisting: InputComponent }], template: "<div [ngClass]=\"inputClasses\">\r\n  <ng-container *ngIf=\"headTemplate; then headTemplate\"></ng-container>\r\n\r\n  <div class=\"mc-input-content\">\r\n    <ng-container *ngIf=\"prefixTemplate; then prefixTemplate\"></ng-container>\r\n\r\n    <textarea\r\n      #textarea\r\n      [(ngModel)]=\"inputValue\"\r\n      [placeholder]=\"placeholderText\"\r\n      [disabled]=\"disabled\"\r\n      [maxlength]=\"maxLength\"\r\n      class=\"mc-textarea\"\r\n      [ngClass]=\"{\r\n        'mc-textarea-simple': displayType === 'simple',\r\n        'mc-textarea-disabled': disabled\r\n      }\"\r\n      [ngStyle]=\"textareaStyle\"\r\n      [attr.aria-label]=\"'Input.ariaLabel' | translate\"\r\n      [attr.aria-disabled]=\"disabled\"\r\n      (input)=\"onInput()\"\r\n      (change)=\"onChange($event)\"\r\n      (compositionstart)=\"onCompositionStart()\"\r\n      (compositionend)=\"onCompositionEnd()\"\r\n      (keydown)=\"onKeydown($event)\"\r\n      (focus)=\"onFocus($event)\"\r\n      (blur)=\"onBlur($event)\"\r\n    ></textarea>\r\n    <ng-container *ngIf=\"suffixTemplate; then suffixTemplate\"></ng-container>\r\n\r\n    <ng-container *ngIf=\"displayType === 'simple'\">\r\n      <ng-container *ngIf=\"buttonTemplate; else defaultButton\">\r\n        <ng-container\r\n          *ngIf=\"buttonTemplate; then buttonTemplate\"\r\n        ></ng-container>\r\n      </ng-container>\r\n      <ng-template #defaultButton>\r\n        <mc-button\r\n          [disabled]=\"disabled || (!loading && !inputValue)\"\r\n          [loading]=\"loading\"\r\n          [inputValue]=\"inputValue\"\r\n          [sendBtnVariant]=\"sendBtnVariant\"\r\n          (submit)=\"onButtonSubmit($event)\"\r\n          (cancel)=\"onButtonCancel()\"\r\n          (change)=\"onButtonChange($event)\"\r\n        ></mc-button>\r\n      </ng-template>\r\n    </ng-container>\r\n  </div>\r\n\r\n  <div *ngIf=\"displayType === 'full'\" class=\"mc-input-foot\">\r\n    <div class=\"mc-input-foot-left\">\r\n      <ng-container *ngIf=\"extraTemplate; then extraTemplate\"></ng-container>\r\n      <span *ngIf=\"showCount\" id=\"mc-input-count\" class=\"mc-input-foot-count\">\r\n        {{ inputValue.length }}{{ !maxLength ? \"\" : \"/\" + maxLength }}\r\n      </span>\r\n    </div>\r\n\r\n    <ng-container *ngIf=\"buttonTemplate; else defaultFooterButton\">\r\n      <ng-container *ngIf=\"buttonTemplate; then buttonTemplate\"></ng-container>\r\n    </ng-container>\r\n    <ng-template #defaultFooterButton>\r\n      <mc-button\r\n        [disabled]=\"disabled || (!loading && !inputValue)\"\r\n        [loading]=\"loading\"\r\n        [inputValue]=\"inputValue\"\r\n        [sendBtnVariant]=\"sendBtnVariant\"\r\n        (submit)=\"onButtonSubmit($event)\"\r\n        (cancel)=\"onButtonCancel()\"\r\n        (change)=\"onButtonChange($event)\"\r\n      ></mc-button>\r\n    </ng-template>\r\n  </div>\r\n</div>\r\n", styles: ["@charset \"UTF-8\";body[ui-theme=infinity-theme]{--mc-text: #aeaeae;--mc-box-shadow: rgba(25, 25, 25, .06)}body[ui-theme=galaxy-theme]{--mc-text: #4e5057;--mc-box-shadow: rgba(206, 209, 219, .06)}.mc-input{display:flex;flex-direction:column;width:100%;padding:12px 0;border:1px solid var(--devui-form-control-line, #d7d8da);border-radius:16px;box-sizing:border-box;background-color:var(--devui-base-bg, #ffffff)}.mc-input.mc-input-simple{border-radius:24px}.mc-input.mc-input-simple .mc-input-content{padding:0 20px}.mc-input.mc-input-borderless{border:none;box-shadow:0 1px 8px 0 var(--mc-box-shadow, rgba(25, 25, 25, .06))}.mc-input.mc-input-disabled{background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-input .mc-input-content{display:flex;align-items:flex-end;padding:0 16px}.mc-input .mc-input-foot{display:flex;justify-content:space-between;align-items:center;height:32px;padding:0 16px}.mc-input .mc-input-foot .mc-input-foot-left{flex:1;height:100%;display:flex;align-items:center}.mc-input .mc-input-foot .mc-input-foot-left .mc-input-foot-count{color:var(--mc-text, #aeaeae);font-size:var(--devui-font-size-sm, 12px)}.mc-textarea{width:100%;height:64px;padding:4px 0;color:var(--devui-text, #252b3a);font-size:var(--devui-font-size, 14px);background-color:var(--devui-form-control-bg, #ffffff);vertical-align:middle;outline:none;box-sizing:border-box;resize:none;border:none}.mc-textarea.mc-textarea-simple{height:32px}.mc-textarea.mc-textarea-disabled{color:var(--devui-disabled-text, #cfd0d3);background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-textarea::placeholder{color:var(--devui-placeholder, #babbc0)}\n"] }]
        }], ctorParameters: () => [{ type: LocaleService }], propDecorators: { value: [{
                type: Input
            }], placeholder: [{
                type: Input
            }], disabled: [{
                type: Input
            }], displayType: [{
                type: Input
            }], variant: [{
                type: Input
            }], sendBtnVariant: [{
                type: Input
            }], loading: [{
                type: Input
            }], showCount: [{
                type: Input
            }], maxLength: [{
                type: Input
            }], submitShortKey: [{
                type: Input
            }], autofocus: [{
                type: Input
            }], autosize: [{
                type: Input
            }], change: [{
                type: Output
            }], submit: [{
                type: Output
            }], cancel: [{
                type: Output
            }], focus: [{
                type: Output
            }], blur: [{
                type: Output
            }], textareaElement: [{
                type: ViewChild,
                args: ['textarea']
            }], headTemplate: [{
                type: ContentChild,
                args: ['head']
            }], prefixTemplate: [{
                type: ContentChild,
                args: ['prefix']
            }], suffixTemplate: [{
                type: ContentChild,
                args: ['suffix']
            }], buttonTemplate: [{
                type: ContentChild,
                args: ['button']
            }], extraTemplate: [{
                type: ContentChild,
                args: ['extra']
            }] } });

class InputModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: InputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.10", ngImport: i0, type: InputModule, imports: [CommonModule,
            FormsModule,
            ButtonComponent,
            SendIconComponent,
            InputComponent], exports: [InputComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: InputModule, imports: [CommonModule,
            FormsModule,
            ButtonComponent,
            InputComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: InputModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [],
                    imports: [
                        CommonModule,
                        FormsModule,
                        ButtonComponent,
                        SendIconComponent,
                        InputComponent
                    ],
                    exports: [InputComponent],
                }]
        }] });

class MDCardService {
    constructor() {
        this.xssWhiteList = getDefaultWhiteList();
        this.cssWhiteList = getDefaultCSSWhiteList();
        this.setDefaultXss();
    }
    setDefaultXss() {
        this.xssWhiteList['input'] = ['type', 'checked', 'disabled', 'class'];
        this.xssWhiteList['label'] = ['for'];
        this.xssWhiteList['ul'] = ['class'];
        this.xssWhiteList['div'] = ['class', 'key'];
        this.xssWhiteList['a'] = ['href', 'class', 'target', 'name'];
        this.xssWhiteList['ol'] = ['start'];
        this.xssWhiteList['p'] = ['class'];
        this.xssWhiteList['span'] = ['style', 'class', 'title', 'id'];
        this.xssWhiteList['svg'] = ['style', 'class', 'width', 'height', 'viewbox', 'preserveaspectratio', 'id', 'fill', 'stroke'];
        this.xssWhiteList['path'] = ['style', 'class', 'd', 'id', 'fill', 'stroke'];
        this.xssWhiteList['th'] = ['style'];
        this.xssWhiteList['td'] = ['style'];
    }
    onIgnoreTagAttr(tag, name, value, isWhiteAttr) {
        if (!isWhiteAttr && (name === 'id' || (tag === 'span' && name === 'style'))) {
            return name + '=' + value;
        }
        return undefined;
    }
    getXssWhiteList() {
        return this.xssWhiteList;
    }
    setXssWhiteList(list) {
        this.xssWhiteList = list;
    }
    setCustomXssRules(rules) {
        if (rules) {
            rules.forEach((rule) => {
                if (rule['value'] === null) {
                    delete this.xssWhiteList[rule['key']];
                }
                else {
                    this.xssWhiteList[rule['key']] = rule['value'];
                }
            });
        }
    }
    setMdPlugins(plugins, mdt) {
        if (plugins && plugins.length) {
            plugins.forEach(item => {
                const { plugin, opts } = item;
                mdt.use(plugin, opts);
            });
        }
    }
    filterHtml(html) {
        return filterXSS(html, {
            whiteList: this.xssWhiteList,
            onIgnoreTagAttr: this.onIgnoreTagAttr,
            css: {
                whiteList: Object.assign({}, this.cssWhiteList, {
                    top: true,
                    left: true,
                    bottom: true,
                    right: true,
                }),
            },
        });
    }
}

class MermaidService {
    constructor(config = {}) {
        this.config = config;
        this.mermaidInstance = null;
        this.isLoading = false;
        this.lastValidResult = '';
        this.viewStateMap = new WeakMap();
        this.containerHeight = 400;
    }
    async loadMermaid() {
        if (this.mermaidInstance) {
            return this.mermaidInstance;
        }
        if (this.isLoading) {
            return new Promise((resolve) => {
                const checkInstance = () => {
                    if (this.mermaidInstance) {
                        resolve(this.mermaidInstance);
                    }
                    else {
                        setTimeout(checkInstance, 50);
                    }
                };
                checkInstance();
            });
        }
        this.isLoading = true;
        try {
            const { default: mermaid } = await import('mermaid');
            mermaid.initialize({
                theme: this.config.theme || 'default',
                startOnLoad: false,
                suppressErrorRendering: true,
                ...this.config
            });
            this.mermaidInstance = mermaid;
            return mermaid;
        }
        catch (error) {
            console.error('Failed to load mermaid:', error);
            throw new Error('Failed to load mermaid library');
        }
        finally {
            this.isLoading = false;
        }
    }
    async renderToContainer(container, code, theme = 'light') {
        const svgStr = await this.renderMermaid(code, theme);
        container.innerHTML = svgStr;
        const svg = container.querySelector('svg');
        if (svg) {
            this.initViewState(container, svg);
            this.applyTransform(container, svg);
            svg.addEventListener('mousedown', (e) => this.onSvgMouseDown(e, container, svg));
        }
    }
    initViewState(container, svg) {
        // 获取svg的viewBox或宽高
        let vb = svg.getAttribute('viewBox');
        let svgW = 0, svgH = 0;
        if (vb) {
            const arr = vb.split(/\s+/);
            svgW = parseFloat(arr[2]);
            svgH = parseFloat(arr[3]);
        }
        else {
            svgW = svg.width.baseVal.value || svg.getBoundingClientRect().width;
            svgH = svg.height.baseVal.value || svg.getBoundingClientRect().height;
        }
        const contW = container.clientWidth || 0;
        const contH = this.containerHeight;
        let scale = 1;
        if (svgW && svgH && contW && contH) {
            scale = Math.min(contW / svgW, contH / svgH, 1);
        }
        this.viewStateMap.set(container, {
            scale,
            offsetX: 0,
            offsetY: 0,
            dragging: false,
            dragStart: { x: 0, y: 0 },
            lastOffset: { x: 0, y: 0 },
        });
    }
    applyTransform(container, svg) {
        const state = this.viewStateMap.get(container);
        if (!state)
            return;
        svg.style.position = 'absolute';
        svg.style.left = '50%';
        svg.style.top = '50%';
        svg.style.transform = `translate(-50%, -50%) translate(${state.offsetX}px, ${state.offsetY}px) scale(${state.scale})`;
        svg.style.transformOrigin = 'center center';
        svg.style.cursor = state.dragging ? 'grabbing' : 'grab';
    }
    zoomIn(container) {
        const svg = container.querySelector('svg');
        const state = this.viewStateMap.get(container);
        if (svg && state) {
            state.scale = Math.min(state.scale + 0.2, 3);
            this.applyTransform(container, svg);
        }
    }
    zoomOut(container) {
        const svg = container.querySelector('svg');
        const state = this.viewStateMap.get(container);
        if (svg && state) {
            state.scale = Math.max(state.scale - 0.2, 0.2);
            this.applyTransform(container, svg);
        }
    }
    reset(container) {
        const svg = container.querySelector('svg');
        if (svg) {
            this.initViewState(container, svg);
            this.applyTransform(container, svg);
        }
    }
    async download(container, filename = 'diagram.png') {
        const svg = container.querySelector('svg');
        if (!svg)
            return;
        try {
            const clonedSvg = svg.cloneNode(true);
            const svgData = new XMLSerializer().serializeToString(clonedSvg);
            const svgUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgData)}`;
            const img = new Image();
            await new Promise((resolve, reject) => {
                img.onload = () => resolve();
                img.onerror = (e) => reject(new Error('Image loading failed'));
                img.src = svgUrl;
            });
            const canvas = document.createElement('canvas');
            const ctx = canvas.getContext('2d');
            if (!ctx)
                throw new Error('Canvas context not available');
            canvas.width = img.width * 2;
            canvas.height = img.height * 2;
            ctx.fillStyle = 'white';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            ctx.drawImage(img, 0, 0);
            canvas.toBlob((blob) => {
                if (!blob) {
                    console.error('Failed to create blob from canvas');
                    return;
                }
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url;
                a.download = filename;
                document.body.appendChild(a);
                a.click();
                setTimeout(() => {
                    document.body.removeChild(a);
                    URL.revokeObjectURL(url);
                }, 100);
            }, 'image/png');
        }
        catch (error) {
            console.error('Failed to download diagram:', error);
        }
    }
    onSvgMouseDown(e, container, svg) {
        const state = this.viewStateMap.get(container);
        if (!state)
            return;
        state.dragging = true;
        state.dragStart = { x: e.clientX, y: e.clientY };
        state.lastOffset = { x: state.offsetX, y: state.offsetY };
        const move = (ev) => this.onSvgMouseMove(ev, container, svg);
        const up = () => this.onSvgMouseUp(container, svg, move, up);
        document.addEventListener('mousemove', move);
        document.addEventListener('mouseup', up);
        this.applyTransform(container, svg);
    }
    onSvgMouseMove(e, container, svg) {
        const state = this.viewStateMap.get(container);
        if (!state || !state.dragging)
            return;
        state.offsetX = state.lastOffset.x + (e.clientX - state.dragStart.x);
        state.offsetY = state.lastOffset.y + (e.clientY - state.dragStart.y);
        this.applyTransform(container, svg);
    }
    onSvgMouseUp(container, svg, move, up) {
        const state = this.viewStateMap.get(container);
        if (!state)
            return;
        state.dragging = false;
        document.removeEventListener('mousemove', move);
        document.removeEventListener('mouseup', up);
        this.applyTransform(container, svg);
    }
    async renderMermaid(code, theme = 'light') {
        try {
            const mermaid = await this.loadMermaid();
            if (this.config.theme !== theme) {
                mermaid.initialize({
                    startOnLoad: false,
                    suppressErrorRendering: true,
                    theme: theme === 'dark' ? 'dark' : 'default',
                    ...this.config
                });
            }
            const id = `mc_mermaid_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
            const { svg } = await mermaid.render(id, code);
            this.lastValidResult = svg;
            return svg;
        }
        catch (error) {
            return this.lastValidResult;
        }
    }
    // 设置配置
    setConfig(config = {}) {
        this.config = {
            theme: 'default',
            ...config
        };
    }
}

class CodeBlockFoundation extends BaseFoundation {
    constructor(adapter) {
        super({ ...adapter });
        this.toggleExpand = () => {
            this.setState({ expanded: !this.getStates().expanded });
        };
        this.zoomOut = () => {
            const container = this._adapter.getContainer();
            if (container && this.mermaidService) {
                this.mermaidService.zoomOut(container);
            }
        };
        this.zoomIn = () => {
            const container = this._adapter.getContainer();
            if (container && this.mermaidService) {
                this.mermaidService.zoomIn(container);
            }
        };
        this.checkIsMermaid = () => {
            const { enableMermaid, language } = this.getProps();
            return enableMermaid && language?.toLowerCase() === 'mermaid';
        };
        this.download = () => {
            const container = this._adapter.getContainer();
            if (container && this.mermaidService) {
                this.mermaidService.download(container);
            }
        };
        this.handleCopySuccess = () => {
            this.setState({ copied: true });
            setTimeout(() => {
                this.setState({ copied: false });
            }, 1500);
        };
        this.updateHighlightedCode = () => {
            const { code, language } = this.getProps();
            let highlightedCode = '';
            try {
                const typeIndex = code.indexOf(`<span class="mc-typewriter`);
                if (language && hljs.getLanguage(language)) {
                    if (typeIndex !== -1) {
                        highlightedCode =
                            hljs.highlight(code.slice(0, typeIndex), {
                                language,
                            }).value + code.slice(typeIndex);
                    }
                    else {
                        highlightedCode = hljs.highlight(code, {
                            language,
                        }).value;
                    }
                }
                else {
                    if (typeof hljs.highlightAuto !== 'undefined') {
                        if (typeIndex !== -1) {
                            highlightedCode =
                                hljs.highlightAuto(code.slice(0, typeIndex)).value +
                                    code.slice(typeIndex);
                        }
                        else {
                            highlightedCode = hljs.highlightAuto(code).value;
                        }
                    }
                    else {
                        highlightedCode = this.mdCardService.filterHtml(code);
                    }
                }
            }
            catch (_) {
                highlightedCode = code;
            }
            this._adapter.highlightCodeChange(highlightedCode, language);
        };
        this.renderMermaid = async () => {
            const { code, theme, mermaidConfig, } = this.getProps();
            const { mermaidContentRef } = this.getStates();
            const isMermaid = this.checkIsMermaid();
            if (!isMermaid || !code || !mermaidContentRef) {
                return;
            }
            if (!this.mermaidService) {
                try {
                    this.mermaidService = new MermaidService();
                    const config = {
                        theme: theme === 'dark' ? 'dark' : 'default',
                        ...mermaidConfig,
                    };
                    this.mermaidService.setConfig(config);
                }
                catch (error) {
                    console.error('Failed to load MermaidService:', error);
                    return;
                }
            }
            this.nextTick(async () => {
                const container = mermaidContentRef.nativeElement;
                if (container) {
                    // 移除打字效果相关的span标签
                    const cleanCode = code.replace(/<span[^>]*\bclass\s*=\s*['"]mc-typewriter[^>]*>([\s\S]*?)<\/span>/g, `$1`);
                    await this.mermaidService?.renderToContainer(container, cleanCode, theme);
                }
            });
        };
        this.mdCardService = new MDCardService();
    }
    copyCodeInternal() {
        const { code } = this.getProps();
        if (navigator.clipboard) {
            navigator.clipboard.writeText(code).then(() => {
                this.handleCopySuccess();
            });
        }
        else {
            const textarea = document.createElement('textarea');
            textarea.style.position = 'fixed';
            textarea.style.top = '-9999px';
            textarea.style.left = '-9999px';
            textarea.style.zIndex = '-1';
            textarea.value = code;
            document.body.appendChild(textarea);
            textarea.select();
            document.execCommand('copy');
            document.body.removeChild(textarea);
            this.handleCopySuccess();
        }
    }
}

class CodeBlockComponent extends BaseComponent {
    get showMermaidDiagram() {
        return this._showMermaidDiagram;
    }
    set showMermaidDiagram(value) {
        if (this._showMermaidDiagram !== value) {
            this._showMermaidDiagram = value;
            // 当切换为显示图表且当前是mermaid类型时，渲染图表
            if (value && this.isMermaid) {
                // 在视图更新后渲染mermaid
                setTimeout(() => {
                    this.renderMermaid();
                });
            }
        }
    }
    constructor(cdr) {
        super();
        this.cdr = cdr;
        this.code = '';
        this.language = '';
        this.blockIndex = 0;
        this.theme = 'light';
        this.enableMermaid = false;
        this.mermaidConfig = {};
        this.contentTemplate = null;
        this.headerTemplate = null;
        this.actionsTemplate = null;
        this.expanded = true;
        this.copied = false;
        this.mermaidContent = '';
        this._showMermaidDiagram = true;
        this.highlightedCode = '';
        this.isMermaid = false;
        this.copySubject = new Subject();
        this.copySubject
            .pipe(debounceTime(300))
            .subscribe(() => this.copyCodeInternal());
        this.foundation = new CodeBlockFoundation(this.adapter);
    }
    get adapter() {
        return {
            ...super.adapter,
            getContainer: () => {
                return this.mermaidContentRef.nativeElement;
            },
            highlightCodeChange: (highlightedCode, language) => {
                this.highlightedCode = highlightedCode;
                if (this.codeElementRef?.nativeElement) {
                    const newElement = document.createElement('code');
                    newElement.className = `hljs language-${language}`;
                    newElement.innerHTML = highlightedCode;
                    morphdom(this.codeElementRef.nativeElement, newElement);
                }
            },
        };
    }
    switchShowMermaid(show) {
        this.showMermaidDiagram = show;
        if (!this.showMermaidDiagram) {
            this.codeElementTemplates.changes.subscribe(() => {
                if (this.codeElementRef?.nativeElement && !this.showMermaidDiagram) {
                    this.codeElementRef.nativeElement.innerHTML = this.highlightedCode;
                }
            });
        }
        this.cdr.detectChanges();
    }
    ngOnInit() {
        this.checkIsMermaid();
        this.updateHighlightedCode();
        if (this.isMermaid) {
            this.renderMermaid();
        }
    }
    ngAfterViewInit() {
        this.updateHighlightedCode();
        if (this.isMermaid) {
            this.renderMermaid();
        }
    }
    ngOnChanges(changes) {
        if (changes['code'] || changes['language']) {
            this.checkIsMermaid();
            this.updateHighlightedCode();
        }
        if (changes['enableMermaid'] || changes['theme'] || changes['code']) {
            this.checkIsMermaid();
            if (this.isMermaid) {
                this.renderMermaid();
            }
        }
        if (changes['showMermaidDiagram'] &&
            this.isMermaid &&
            this.showMermaidDiagram) {
            this.renderMermaid();
        }
    }
    checkIsMermaid() {
        this.isMermaid = this.foundation.checkIsMermaid();
    }
    updateHighlightedCode() {
        setTimeout(() => {
            this.foundation.updateHighlightedCode();
        });
    }
    zoomIn() {
        this.foundation.zoomIn();
        this.cdr.detectChanges();
    }
    zoomOut() {
        this.foundation.zoomOut();
        this.cdr.detectChanges();
    }
    download() {
        this.foundation.download();
    }
    async renderMermaid() {
        await this.foundation.renderMermaid();
    }
    toggleExpand() {
        this.foundation.toggleExpand();
        this.cdr.detectChanges();
    }
    copyCode() {
        this.copySubject.next();
    }
    copyCodeInternal() {
        this.foundation.copyCodeInternal();
        this.cdr.detectChanges();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CodeBlockComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.10", type: CodeBlockComponent, isStandalone: false, selector: "mc-code-block", inputs: { code: "code", language: "language", blockIndex: "blockIndex", theme: "theme", enableMermaid: "enableMermaid", mermaidConfig: "mermaidConfig", contentTemplate: "contentTemplate", headerTemplate: "headerTemplate", actionsTemplate: "actionsTemplate" }, viewQueries: [{ propertyName: "rootRef", first: true, predicate: ["rootRef"], descendants: true }, { propertyName: "mermaidContentRef", first: true, predicate: ["mermaidContent"], descendants: true }, { propertyName: "codeElementRef", first: true, predicate: ["codeElement"], descendants: true }, { propertyName: "codeElementTemplates", predicate: ["codeElementTemplate"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div\r\n  class=\"mc-code-block\"\r\n  [ngClass]=\"theme === 'dark' ? 'mc-code-block-dark' : 'mc-code-block-light'\"\r\n  #rootRef\r\n>\r\n  <div class=\"mc-code-block-header\" *ngIf=\"!headerTemplate\">\r\n    <span class=\"mc-code-lang\">{{ language }}</span>\r\n    <ng-container *ngIf=\"!actionsTemplate\">\r\n      <div class=\"mc-code-block-actions\">\r\n        <div *ngIf=\"isMermaid\" style=\"margin-right: 8px\">\r\n          <ul\r\n            class=\"mc-diagram-switch\"\r\n            [ngClass]=\"{ 'mc-show-code': !showMermaidDiagram }\"\r\n          >\r\n            <li\r\n              (click)=\"switchShowMermaid(true)\"\r\n              [ngClass]=\"{ 'mc-diagram-switch-active': showMermaidDiagram }\"\r\n            >\r\n              \u56FE\u8868\r\n            </li>\r\n            <li\r\n              (click)=\"switchShowMermaid(false)\"\r\n              [ngClass]=\"{ 'mc-diagram-switch-active': !showMermaidDiagram }\"\r\n            >\r\n              \u4EE3\u7801\r\n            </li>\r\n          </ul>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          [title]=\"'Md.zoomIn' | translate\"\r\n          (click)=\"zoomIn()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              id=\"enlarge\"\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M7.16666667,1 C10.572409,1 13.3333333,3.76092429 13.3333333,7.16666667 C13.3333333,8.68984984 12.781084,10.0840543 11.8658888,11.1599767 L14.4225201,13.7154466 C14.6177822,13.9107088 14.6177822,14.2272912 14.4225201,14.4225534 C14.2489537,14.5961197 13.9795293,14.6154049 13.7846612,14.4804088 L13.7154133,14.4225534 L11.158968,11.8667467 C10.083183,12.7814291 8.68937384,13.3333333 7.16666667,13.3333333 C3.76092429,13.3333333 1,10.572409 1,7.16666667 C1,3.76092429 3.76092429,1 7.16666667,1 Z M7.16666667,2 C4.31320904,2 2,4.31320904 2,7.16666667 C2,10.0201243 4.31320904,12.3333333 7.16666667,12.3333333 C10.0201243,12.3333333 12.3333333,10.0201243 12.3333333,7.16666667 C12.3333333,4.31320904 10.0201243,2 7.16666667,2 Z M7.16666667,4.66666667 C7.41212656,4.66666667 7.61627504,4.84354183 7.658611,5.07679103 L7.66666667,5.16666667 L7.666,6.668 L9.16601582,6.66666666 C9.44215796,6.66630764 9.66630679,6.88987368 9.66666668,7.16601582 C9.66698576,7.4114755 9.49037648,7.61585405 9.25718258,7.65849359 L9.16731751,7.66666666 L7.666,7.668 L7.66666667,9.16666667 C7.66666667,9.44280904 7.44280904,9.66666667 7.16666667,9.66666667 C6.92120678,9.66666667 6.7170583,9.48979151 6.67472234,9.2565423 L6.66666667,9.16666667 L6.666,7.669 L5.17251751,7.67186668 C4.89637537,7.6722257 4.67222654,7.44865965 4.67186666,7.17251751 C4.67154758,6.92705783 4.84815685,6.72267929 5.08135075,6.68003974 L5.17121582,6.67186709 L6.666,6.669 L6.66666667,5.16666667 C6.66666667,4.89052429 6.89052429,4.66666667 7.16666667,4.66666667 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u7F29\u5C0F\"\r\n          (click)=\"zoomOut()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              id=\"zoom-out\"\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M7.16666667,1 C10.572409,1 13.3333333,3.76092429 13.3333333,7.16666667 C13.3333333,8.68984984 12.781084,10.0840543 11.8658888,11.1599767 L14.4225201,13.7154466 C14.6177822,13.9107088 14.6177822,14.2272912 14.4225201,14.4225534 C14.2489537,14.5961197 13.9795293,14.6154049 13.7846612,14.4804088 L13.7154133,14.4225534 L11.158968,11.8667467 C10.083183,12.7814291 8.68937384,13.3333333 7.16666667,13.3333333 C3.76092429,13.3333333 1,10.572409 1,7.16666667 C1,3.76092429 3.76092429,1 7.16666667,1 Z M7.16666667,2 C4.31320904,2 2,4.31320904 2,7.16666667 C2,10.0201243 4.31320904,12.3333333 7.16666667,12.3333333 C10.0201243,12.3333333 12.3333333,10.0201243 12.3333333,7.16666667 C12.3333333,4.31320904 10.0201243,2 7.16666667,2 Z M9.16601582,6.66666666 C9.44215796,6.66630764 9.66630679,6.88987368 9.66666668,7.16601582 C9.66698576,7.4114755 9.49037648,7.61585405 9.25718258,7.65849359 L9.16731751,7.66666666 L5.17251751,7.67186668 C4.89637537,7.6722257 4.67222654,7.44865965 4.67186666,7.17251751 C4.67154758,6.92705783 4.84815685,6.72267929 5.08135075,6.68003974 L5.17121582,6.67186709 L9.16601582,6.66666666 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u4E0B\u8F7D\"\r\n          (click)=\"download()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <g>\r\n                <path\r\n                  d=\"M14.5,14 C14.7761424,14 15,14.2238576 15,14.5 C15,14.7761424 14.7761424,15 14.5,15 L1.5,15 C1.22385763,15 1,14.7761424 1,14.5 C1,14.2238576 1.22385763,14 1.5,14 L14.5,14 Z M8,1 C8.24545989,1 8.44960837,1.17687516 8.49194433,1.41012437 L8.5,1.5 L8.5,10.793 L11.6464466,7.64644661 C11.820013,7.47288026 12.0894374,7.45359511 12.2843055,7.58859116 L12.3535534,7.64644661 C12.5271197,7.82001296 12.5464049,8.08943736 12.4114088,8.2843055 L12.3535534,8.35355339 L8.35355339,12.3535534 L8.34128643,12.3654113 C8.32881868,12.3770608 8.31575424,12.3880797 8.30214392,12.3984173 L8.35355339,12.3535534 C8.32671912,12.3803877 8.29759357,12.4035342 8.26680652,12.422993 C8.25568247,12.4299807 8.24404667,12.4367067 8.23212724,12.4429657 C8.21827569,12.4502504 8.20453886,12.4566485 8.1905951,12.4623894 C8.17802507,12.4675915 8.16473685,12.4724419 8.15119917,12.4767316 C8.13583471,12.481552 8.12047425,12.4856039 8.10498705,12.4889143 C8.09430622,12.4912471 8.08325248,12.4932298 8.07207924,12.494843 C8.05487076,12.4972949 8.03773477,12.498877 8.02056948,12.4995793 C8.01375728,12.4998604 8.00689494,12.5 8,12.5 L7.98043349,12.4996194 C7.96293275,12.4989382 7.94546098,12.4973429 7.92809589,12.4948333 L8,12.5 C7.96390296,12.5 7.92869933,12.4961748 7.89477235,12.4889078 C7.87952575,12.4856039 7.86416529,12.481552 7.84898836,12.4767587 C7.83526315,12.4724419 7.82197493,12.4675915 7.80896344,12.4622078 C7.79546114,12.4566485 7.78172431,12.4502504 7.76824181,12.443195 C7.75595333,12.4367067 7.74431753,12.4299807 7.73298968,12.422812 C7.72729809,12.4192668 7.72146362,12.4154054 7.7156945,12.4114088 L7.69785608,12.3984173 C7.68424576,12.3880797 7.67118132,12.3770608 7.65871357,12.3654113 L7.64644661,12.3535534 L3.64644661,8.35355339 C3.45118446,8.15829124 3.45118446,7.84170876 3.64644661,7.64644661 C3.82001296,7.47288026 4.08943736,7.45359511 4.2843055,7.58859116 L4.35355339,7.64644661 L7.5,10.793 L7.5,1.5 C7.5,1.22385763 7.72385763,1 8,1 Z\"\r\n                  fill=\"#71757F\"\r\n                ></path>\r\n              </g>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u5C55\u5F00/\u6298\u53E0\"\r\n          (click)=\"toggleExpand()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M4.715694,14.4114091 C4.910563,14.5464051 5.179987,14.5271201 5.353553,14.3535531 L5.353553,14.3535531 L7.99999988,11.7070001 L10.646447,14.3535531 L10.715694,14.4114091 C10.910563,14.5464051 11.179987,14.5271201 11.353553,14.3535531 C11.548816,14.1582911 11.548816,13.8417091 11.353553,13.6464471 L11.353553,13.6464471 L8.353553,10.6464471 L8.284306,10.5885911 C8.089437,10.4535951 7.820013,10.4728801 7.646447,10.6464471 L7.646447,10.6464471 L4.646447,13.6464471 L4.588591,13.7156941 C4.453595,13.9105631 4.47288,14.1799871 4.646447,14.3535531 L4.646447,14.3535531 L4.715694,14.4114091 Z M14.5,7.50000012 C14.776142,7.50000012 15,7.72385812 15,8.00000012 C15,8.27614212 14.776142,8.50000012 14.5,8.50000012 L1.5,8.50000012 C1.223858,8.50000012 1,8.27614212 1,8.00000012 C1,7.72385812 1.223858,7.50000012 1.5,7.50000012 L14.5,7.50000012 Z M8.284306,5.41140912 L8.353553,5.35355312 L11.353553,2.35355312 C11.548816,2.15829112 11.548816,1.84170912 11.353553,1.64644712 C11.179987,1.47288012 10.910563,1.45359512 10.715694,1.58859112 L10.646447,1.64644712 L7.99999988,4.29300012 L5.353553,1.64644712 C5.179987,1.47288012 4.910563,1.45359512 4.715694,1.58859112 L4.646447,1.64644712 C4.47288,1.82001312 4.453595,2.08943712 4.588591,2.28430612 L4.646447,2.35355312 L7.646447,5.35355312 C7.820013,5.52712012 8.089437,5.54640512 8.284306,5.41140912 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          class=\"mc-action-btn mc-copy-btn\"\r\n          title=\"\u590D\u5236\"\r\n          (click)=\"copyCode()\"\r\n        >\r\n          @if(copied) {\r\n          <span>\r\n            <svg\r\n              width=\"16px\"\r\n              height=\"16px\"\r\n              viewBox=\"0 0 16 16\"\r\n              version=\"1.1\"\r\n              xmlns=\"http://www.w3.org/2000/svg\"\r\n              xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n            >\r\n              <defs>\r\n                <polygon\r\n                  id=\"path-1\"\r\n                  points=\"6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459\"\r\n                ></polygon>\r\n              </defs>\r\n              <g\r\n                id=\"status/whiteBG/correct\"\r\n                stroke=\"none\"\r\n                stroke-width=\"1\"\r\n                fill=\"none\"\r\n                fill-rule=\"evenodd\"\r\n              >\r\n                <mask id=\"mask-2\" fill=\"white\">\r\n                  <use xlink:href=\"#path-1\"></use>\r\n                </mask>\r\n                <use id=\"Mask\" fill=\"#3DCCA6\" xlink:href=\"#path-1\"></use>\r\n              </g>\r\n            </svg>\r\n          </span>\r\n          } @else {\r\n          <span>\r\n            <svg\r\n              width=\"16px\"\r\n              height=\"16px\"\r\n              viewBox=\"0 0 16 16\"\r\n              version=\"1.1\"\r\n              xmlns=\"http://www.w3.org/2000/svg\"\r\n              xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n            >\r\n              <g\r\n                id=\"\u9875\u9762-1\"\r\n                stroke=\"none\"\r\n                stroke-width=\"1\"\r\n                fill=\"none\"\r\n                fill-rule=\"evenodd\"\r\n              >\r\n                <g\r\n                  transform=\"translate(-592.000000, -204.000000)\"\r\n                >\r\n                  <g\r\n                    transform=\"translate(560.000000, 180.000000)\"\r\n                  >\r\n                    <text\r\n                      font-family=\"PingFangSC-Regular, PingFang SC\"\r\n                      font-size=\"12\"\r\n                      font-weight=\"normal\"\r\n                      line-spacing=\"16\"\r\n                      fill=\"#71757F\"\r\n                    >\r\n                      <tspan x=\"27.136\" y=\"61\">\u590D\u5236</tspan>\r\n                    </text>\r\n                  </g>\r\n                  <path\r\n                    d=\"M604.5,206 C605.279696,206 605.920449,206.594888 605.993133,207.35554 L606,207.5 L606,214.5 C606,215.279696 605.405112,215.920449 604.64446,215.993133 L604.5,216 L604,216 L604,216.5 C604,217.279696 603.405112,217.920449 602.64446,217.993133 L602.5,218 L595.5,218 C594.671573,218 594,217.328427 594,216.5 L594,216.5 L594,209.5 C594,208.671573 594.671573,208 595.5,208 L595.5,208 L596,208 L596,207.5 C596,206.720304 596.594888,206.079551 597.35554,206.006867 L597.5,206 L604.5,206 Z M602.5,209 L595.5,209 C595.223858,209 595,209.223858 595,209.5 L595,209.5 L595,216.5 C595,216.776142 595.223858,217 595.5,217 L595.5,217 L602.5,217 C602.776142,217 603,216.776142 603,216.5 L603,216.5 L603,209.5 C603,209.223858 602.776142,209 602.5,209 L602.5,209 Z M604.5,207 L597.5,207 C597.25454,207 597.050392,207.176875 597.008056,207.410124 L597,207.5 L597,208 L602.5,208 C603.279696,208 603.920449,208.594888 603.993133,209.35554 L604,209.5 L604,215 L604.5,215 C604.74546,215 604.949608,214.823125 604.991944,214.589876 L605,214.5 L605,207.5 C605,207.25454 604.823125,207.050392 604.589876,207.008056 L604.5,207 Z\"\r\n                    fill=\"#71757F\"\r\n                    fill-rule=\"nonzero\"\r\n                  ></path>\r\n                </g>\r\n              </g>\r\n            </svg>\r\n          </span>\r\n          }\r\n        </div>\r\n      </div>\r\n    </ng-container>\r\n    <ng-container *ngIf=\"actionsTemplate\">\r\n      <ng-template [ngTemplateOutlet]=\"actionsTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n    </ng-container>\r\n  </div>\r\n  <ng-container *ngIf=\"headerTemplate\">\r\n    <ng-template [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n  </ng-container>\r\n\r\n  <div [ngClass]=\"{ 'mc-block-hidden': !expanded }\" >\r\n    @if (showMermaidDiagram && isMermaid && !contentTemplate) {\r\n    <div class=\"mc-mermaid-content\" #mermaidContent></div>\r\n    } @else if(!contentTemplate) {\r\n    <pre #codeElementTemplate><code #codeElement [ngClass]=\"'hljs language-' + language\" ></code></pre>\r\n    } @else {\r\n    <ng-container *ngIf=\"contentTemplate\">\r\n      <ng-template [ngTemplateOutlet]=\"contentTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n    </ng-container>\r\n    }\r\n  </div>\r\n</div>\r\n", styles: [".mc-markdown-render ::ng-deep .h1,.mc-markdown-render ::ng-deep .h2,.mc-markdown-render ::ng-deep .h3,.mc-markdown-render ::ng-deep .h4,.mc-markdown-render ::ng-deep .h5,.mc-markdown-render ::ng-deep .h6,.mc-markdown-render ::ng-deep h1,.mc-markdown-render ::ng-deep h2,.mc-markdown-render ::ng-deep h3,.mc-markdown-render ::ng-deep h4,.mc-markdown-render ::ng-deep h5,.mc-markdown-render ::ng-deep h6{line-height:1.1;margin:16px 0 12px}.mc-markdown-render ::ng-deep .h1:first-child,.mc-markdown-render ::ng-deep .h2:first-child,.mc-markdown-render ::ng-deep .h3:first-child,.mc-markdown-render ::ng-deep .h4:first-child,.mc-markdown-render ::ng-deep .h5:first-child,.mc-markdown-render ::ng-deep .h6:first-child,.mc-markdown-render ::ng-deep h1:first-child,.mc-markdown-render ::ng-deep h2:first-child,.mc-markdown-render ::ng-deep h3:first-child,.mc-markdown-render ::ng-deep h4:first-child,.mc-markdown-render ::ng-deep h5:first-child,.mc-markdown-render ::ng-deep h6:first-child{margin-top:0}.mc-markdown-render ::ng-deep h1{font-size:32px;line-height:40px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep h3{line-height:28px;font-size:20px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep caption{border:1px dashed var(--devui-line, #d7d8da);border-bottom:0;padding:3px;text-align:center}.mc-markdown-render ::ng-deep p{overflow-wrap:break-word;margin:0;padding:0;line-height:24px}.mc-markdown-render ::ng-deep p:last-child{margin:0}.mc-markdown-render ::ng-deep ul,.mc-markdown-render ::ng-deep ol{margin:0;padding:0;padding-inline-start:1.75em}.mc-markdown-render ::ng-deep ul>li,.mc-markdown-render ::ng-deep ol>li{line-height:21px}.mc-markdown-render ::ng-deep ul{list-style-type:disc}.mc-markdown-render ::ng-deep ul li::marker{font-size:20px}.mc-markdown-render ::ng-deep ol{list-style-type:decimal}.mc-markdown-render ::ng-deep table{margin-bottom:10px;border-collapse:collapse;display:table}.mc-markdown-render ::ng-deep td,.mc-markdown-render ::ng-deep th{padding:5px 10px;border:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-base-bg, #ffffff)}.mc-markdown-render ::ng-deep th{border-top:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-global-bg, #f6f6f8)}.mc-markdown-render ::ng-deep td p{margin:0;padding:0}.mc-markdown-render ::ng-deep blockquote{padding:0 8px;margin:0;color:var(--devui-text-weak, #575d6c);border-left:5px solid var(--devui-dividing-line, #f2f2f3)}.mc-markdown-render ::ng-deep a{color:var(--devui-link, #526ecc);text-decoration:none;cursor:pointer}.mc-markdown-render ::ng-deep a:hover{color:var(--devui-link-active, #526ecc)}.mc-markdown-render ::ng-deep img{max-width:100%}.mc-markdown-render{font-size:var(--devui-font-size, 14px);overflow-x:auto}.mc-markdown-render.mc-markdown-render-dark{color:#ced1db}.mc-markdown-render.mc-markdown-render-light{color:#252b3a}::ng-deep .mc-think-block{color:var(--devui-aide-text, #71757f);border-left:1px solid var(--devui-line, #d7d8da);padding-left:8px;margin-bottom:1rem}::ng-deep .mc-typewriter-color{background-image:-webkit-linear-gradient(left,#191919,#5588f0,#e171ee,#f2c55c);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-gradient{background:linear-gradient(to right,var(--devui-text, #252b3a),var(--devui-base-bg, #ffffff));background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-cursor{font-weight:900;animation:typewriter .8s linear 0s infinite}@keyframes typewriter{0%{opacity:1}50%{opacity:0}to{opacity:1}}.mc-code-block-light ::ng-deep pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-light ::ng-deep code.hljs{padding:3px 5px}.mc-code-block-light ::ng-deep .hljs{background:#fefefe;color:#545454}.mc-code-block-light ::ng-deep .hljs-comment,.mc-code-block-light ::ng-deep .hljs-quote{color:#696969}.mc-code-block-light ::ng-deep .hljs-variable,.mc-code-block-light ::ng-deep .hljs-template-variable,.mc-code-block-light ::ng-deep .hljs-tag,.mc-code-block-light ::ng-deep .hljs-name,.mc-code-block-light ::ng-deep .hljs-selector-id,.mc-code-block-light ::ng-deep .hljs-selector-class,.mc-code-block-light ::ng-deep .hljs-regexp,.mc-code-block-light ::ng-deep .hljs-deletion{color:#d91e18}.mc-code-block-light ::ng-deep .hljs-number,.mc-code-block-light ::ng-deep .hljs-built_in,.mc-code-block-light ::ng-deep .hljs-literal,.mc-code-block-light ::ng-deep .hljs-type,.mc-code-block-light ::ng-deep .hljs-params,.mc-code-block-light ::ng-deep .hljs-meta,.mc-code-block-light ::ng-deep .hljs-link{color:#aa5d00}.mc-code-block-light ::ng-deep .hljs-attribute{color:#aa5d00}.mc-code-block-light ::ng-deep .hljs-string,.mc-code-block-light ::ng-deep .hljs-symbol,.mc-code-block-light ::ng-deep .hljs-bullet,.mc-code-block-light ::ng-deep .hljs-addition{color:green}.mc-code-block-light ::ng-deep .hljs-title,.mc-code-block-light ::ng-deep .hljs-section{color:#007faa}.mc-code-block-light ::ng-deep .hljs-keyword,.mc-code-block-light ::ng-deep .hljs-selector-tag{color:#7928a1}.mc-code-block-light ::ng-deep .hljs-emphasis{font-style:italic}.mc-code-block-light ::ng-deep .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-light ::ng-deep .hljs-addition,.mc-code-block-light ::ng-deep .hljs-attribute,.mc-code-block-light ::ng-deep .hljs-built_in,.mc-code-block-light ::ng-deep .hljs-bullet,.mc-code-block-light ::ng-deep .hljs-comment,.mc-code-block-light ::ng-deep .hljs-link,.mc-code-block-light ::ng-deep .hljs-literal,.mc-code-block-light ::ng-deep .hljs-meta,.mc-code-block-light ::ng-deep .hljs-number,.mc-code-block-light ::ng-deep .hljs-params,.mc-code-block-light ::ng-deep .hljs-string,.mc-code-block-light ::ng-deep .hljs-symbol,.mc-code-block-light ::ng-deep .hljs-type,.mc-code-block-light ::ng-deep .hljs-quote{color:highlight}.mc-code-block-light ::ng-deep .hljs-keyword,.mc-code-block-light ::ng-deep .hljs-selector-tag{font-weight:700}}.mc-code-block-light{border:1px solid #d7d8da;background-color:#f5f5f5}.mc-code-block-light code.hljs{padding:1em}.mc-code-block-light .mc-code-lang,.mc-code-block-light .mc-code-block-actions .mc-copy-btn,.mc-code-block-light .mc-code-block-actions .mc-toggle-btn{color:#252b3a}.mc-code-block-light .mc-code-block-actions .mc-copy-btn:hover,.mc-code-block-light .mc-code-block-actions .mc-toggle-btn:hover{background-color:#ebebeb}.mc-code-block-light .mc-mermaid-content{background:#fefefe}.mc-code-block-dark ::ng-deep pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-dark ::ng-deep code.hljs{padding:3px 5px}.mc-code-block-dark ::ng-deep .hljs{background:#2b2b2b;color:#f8f8f2}.mc-code-block-dark ::ng-deep .hljs-comment,.mc-code-block-dark ::ng-deep .hljs-quote{color:#d4d0ab}.mc-code-block-dark ::ng-deep .hljs-variable,.mc-code-block-dark ::ng-deep .hljs-template-variable,.mc-code-block-dark ::ng-deep .hljs-tag,.mc-code-block-dark ::ng-deep .hljs-name,.mc-code-block-dark ::ng-deep .hljs-selector-id,.mc-code-block-dark ::ng-deep .hljs-selector-class,.mc-code-block-dark ::ng-deep .hljs-regexp,.mc-code-block-dark ::ng-deep .hljs-deletion{color:#ffa07a}.mc-code-block-dark ::ng-deep .hljs-number,.mc-code-block-dark ::ng-deep .hljs-built_in,.mc-code-block-dark ::ng-deep .hljs-literal,.mc-code-block-dark ::ng-deep .hljs-type,.mc-code-block-dark ::ng-deep .hljs-params,.mc-code-block-dark ::ng-deep .hljs-meta,.mc-code-block-dark ::ng-deep .hljs-link{color:#f5ab35}.mc-code-block-dark ::ng-deep .hljs-attribute{color:gold}.mc-code-block-dark ::ng-deep .hljs-string,.mc-code-block-dark ::ng-deep .hljs-symbol,.mc-code-block-dark ::ng-deep .hljs-bullet,.mc-code-block-dark ::ng-deep .hljs-addition{color:#abe338}.mc-code-block-dark ::ng-deep .hljs-title,.mc-code-block-dark ::ng-deep .hljs-section{color:#00e0e0}.mc-code-block-dark ::ng-deep .hljs-keyword,.mc-code-block-dark ::ng-deep .hljs-selector-tag{color:#dcc6e0}.mc-code-block-dark ::ng-deep .hljs-emphasis{font-style:italic}.mc-code-block-dark ::ng-deep .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-dark ::ng-deep .hljs-addition,.mc-code-block-dark ::ng-deep .hljs-attribute,.mc-code-block-dark ::ng-deep .hljs-built_in,.mc-code-block-dark ::ng-deep .hljs-bullet,.mc-code-block-dark ::ng-deep .hljs-comment,.mc-code-block-dark ::ng-deep .hljs-link,.mc-code-block-dark ::ng-deep .hljs-literal,.mc-code-block-dark ::ng-deep .hljs-meta,.mc-code-block-dark ::ng-deep .hljs-number,.mc-code-block-dark ::ng-deep .hljs-params,.mc-code-block-dark ::ng-deep .hljs-string,.mc-code-block-dark ::ng-deep .hljs-symbol,.mc-code-block-dark ::ng-deep .hljs-type,.mc-code-block-dark ::ng-deep .hljs-quote{color:highlight}.mc-code-block-dark ::ng-deep .hljs-keyword,.mc-code-block-dark ::ng-deep .hljs-selector-tag{font-weight:700}}.mc-code-block-dark{border:1px solid #4e5057;background-color:#34363a}.mc-code-block-dark code.hljs{padding:1em}.mc-code-block-dark .mc-code-lang,.mc-code-block-dark .mc-code-block-actions .mc-copy-btn,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn{color:#ced1db}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn:hover,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn:hover{background-color:#393a3e}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn img,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn img{filter:brightness(1.5)}.mc-code-block-dark .mc-mermaid-content{background:#2b2b2b!important}@keyframes collapse-expand{0%{opacity:0;max-height:0}to{opacity:1;max-height:1000px}}@keyframes collapse-collapse{0%{opacity:1;max-height:1000px}to{opacity:0;max-height:0}}.mc-block-hidden{display:none}.collapse-expanded{animation:collapse-expand .5s ease-out}.collapse-collapsed{animation:collapse-collapse .5s ease-in}.mc-code-block{margin:1rem 0;overflow:hidden;border-radius:14px}.mc-code-block pre{margin:0}.mc-code-block .mc-action-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box}.mc-code-block .mc-code-block-header{display:flex;justify-content:space-between;align-items:center;padding:.5rem 1rem}.mc-code-block .mc-code-block-header .mc-code-lang{font-size:14px}.mc-code-block .mc-mermaid-content{position:relative;width:100%;height:400px;overflow:hidden;background:inherit}.mc-code-block .mc-code-block-actions{display:flex;align-items:center}.mc-code-block .mc-code-block-actions .mc-copy-btn,.mc-code-block .mc-code-block-actions .mc-toggle-btn{cursor:pointer;border-radius:4px;font-size:18px;padding:4px}.mc-code-block .mc-diagram-switch{display:flex;align-items:center;list-style:none;margin:0;padding:2px;border-radius:4px;background-color:var(--devui-icon-hover-bg);position:relative;transition:all .3s ease;overflow:hidden;height:24px}.mc-code-block .mc-diagram-switch:before{content:\"\";position:absolute;top:2px;left:2px;width:calc(50% - 2px);height:calc(100% - 4px);background-color:var(--devui-base-bg);border-radius:4px;transition:transform .3s ease;box-shadow:0 1px 2px #0000001a;z-index:1}.mc-code-block .mc-diagram-switch.mc-show-code:before{transform:translate(100%)}.mc-code-block .mc-diagram-switch .mc-diagram-switch-active{text-shadow:0 0 .4px #252b3a}.mc-code-block .mc-diagram-switch li{position:relative;padding:0 8px;margin:0;font-size:12px;cursor:pointer;transition:color .3s ease;z-index:2}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: CodeBlockComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-code-block', standalone: false, template: "<div\r\n  class=\"mc-code-block\"\r\n  [ngClass]=\"theme === 'dark' ? 'mc-code-block-dark' : 'mc-code-block-light'\"\r\n  #rootRef\r\n>\r\n  <div class=\"mc-code-block-header\" *ngIf=\"!headerTemplate\">\r\n    <span class=\"mc-code-lang\">{{ language }}</span>\r\n    <ng-container *ngIf=\"!actionsTemplate\">\r\n      <div class=\"mc-code-block-actions\">\r\n        <div *ngIf=\"isMermaid\" style=\"margin-right: 8px\">\r\n          <ul\r\n            class=\"mc-diagram-switch\"\r\n            [ngClass]=\"{ 'mc-show-code': !showMermaidDiagram }\"\r\n          >\r\n            <li\r\n              (click)=\"switchShowMermaid(true)\"\r\n              [ngClass]=\"{ 'mc-diagram-switch-active': showMermaidDiagram }\"\r\n            >\r\n              \u56FE\u8868\r\n            </li>\r\n            <li\r\n              (click)=\"switchShowMermaid(false)\"\r\n              [ngClass]=\"{ 'mc-diagram-switch-active': !showMermaidDiagram }\"\r\n            >\r\n              \u4EE3\u7801\r\n            </li>\r\n          </ul>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          [title]=\"'Md.zoomIn' | translate\"\r\n          (click)=\"zoomIn()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              id=\"enlarge\"\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M7.16666667,1 C10.572409,1 13.3333333,3.76092429 13.3333333,7.16666667 C13.3333333,8.68984984 12.781084,10.0840543 11.8658888,11.1599767 L14.4225201,13.7154466 C14.6177822,13.9107088 14.6177822,14.2272912 14.4225201,14.4225534 C14.2489537,14.5961197 13.9795293,14.6154049 13.7846612,14.4804088 L13.7154133,14.4225534 L11.158968,11.8667467 C10.083183,12.7814291 8.68937384,13.3333333 7.16666667,13.3333333 C3.76092429,13.3333333 1,10.572409 1,7.16666667 C1,3.76092429 3.76092429,1 7.16666667,1 Z M7.16666667,2 C4.31320904,2 2,4.31320904 2,7.16666667 C2,10.0201243 4.31320904,12.3333333 7.16666667,12.3333333 C10.0201243,12.3333333 12.3333333,10.0201243 12.3333333,7.16666667 C12.3333333,4.31320904 10.0201243,2 7.16666667,2 Z M7.16666667,4.66666667 C7.41212656,4.66666667 7.61627504,4.84354183 7.658611,5.07679103 L7.66666667,5.16666667 L7.666,6.668 L9.16601582,6.66666666 C9.44215796,6.66630764 9.66630679,6.88987368 9.66666668,7.16601582 C9.66698576,7.4114755 9.49037648,7.61585405 9.25718258,7.65849359 L9.16731751,7.66666666 L7.666,7.668 L7.66666667,9.16666667 C7.66666667,9.44280904 7.44280904,9.66666667 7.16666667,9.66666667 C6.92120678,9.66666667 6.7170583,9.48979151 6.67472234,9.2565423 L6.66666667,9.16666667 L6.666,7.669 L5.17251751,7.67186668 C4.89637537,7.6722257 4.67222654,7.44865965 4.67186666,7.17251751 C4.67154758,6.92705783 4.84815685,6.72267929 5.08135075,6.68003974 L5.17121582,6.67186709 L6.666,6.669 L6.66666667,5.16666667 C6.66666667,4.89052429 6.89052429,4.66666667 7.16666667,4.66666667 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u7F29\u5C0F\"\r\n          (click)=\"zoomOut()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              id=\"zoom-out\"\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M7.16666667,1 C10.572409,1 13.3333333,3.76092429 13.3333333,7.16666667 C13.3333333,8.68984984 12.781084,10.0840543 11.8658888,11.1599767 L14.4225201,13.7154466 C14.6177822,13.9107088 14.6177822,14.2272912 14.4225201,14.4225534 C14.2489537,14.5961197 13.9795293,14.6154049 13.7846612,14.4804088 L13.7154133,14.4225534 L11.158968,11.8667467 C10.083183,12.7814291 8.68937384,13.3333333 7.16666667,13.3333333 C3.76092429,13.3333333 1,10.572409 1,7.16666667 C1,3.76092429 3.76092429,1 7.16666667,1 Z M7.16666667,2 C4.31320904,2 2,4.31320904 2,7.16666667 C2,10.0201243 4.31320904,12.3333333 7.16666667,12.3333333 C10.0201243,12.3333333 12.3333333,10.0201243 12.3333333,7.16666667 C12.3333333,4.31320904 10.0201243,2 7.16666667,2 Z M9.16601582,6.66666666 C9.44215796,6.66630764 9.66630679,6.88987368 9.66666668,7.16601582 C9.66698576,7.4114755 9.49037648,7.61585405 9.25718258,7.65849359 L9.16731751,7.66666666 L5.17251751,7.67186668 C4.89637537,7.6722257 4.67222654,7.44865965 4.67186666,7.17251751 C4.67154758,6.92705783 4.84815685,6.72267929 5.08135075,6.68003974 L5.17121582,6.67186709 L9.16601582,6.66666666 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          *ngIf=\"isMermaid && showMermaidDiagram\"\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u4E0B\u8F7D\"\r\n          (click)=\"download()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <g>\r\n                <path\r\n                  d=\"M14.5,14 C14.7761424,14 15,14.2238576 15,14.5 C15,14.7761424 14.7761424,15 14.5,15 L1.5,15 C1.22385763,15 1,14.7761424 1,14.5 C1,14.2238576 1.22385763,14 1.5,14 L14.5,14 Z M8,1 C8.24545989,1 8.44960837,1.17687516 8.49194433,1.41012437 L8.5,1.5 L8.5,10.793 L11.6464466,7.64644661 C11.820013,7.47288026 12.0894374,7.45359511 12.2843055,7.58859116 L12.3535534,7.64644661 C12.5271197,7.82001296 12.5464049,8.08943736 12.4114088,8.2843055 L12.3535534,8.35355339 L8.35355339,12.3535534 L8.34128643,12.3654113 C8.32881868,12.3770608 8.31575424,12.3880797 8.30214392,12.3984173 L8.35355339,12.3535534 C8.32671912,12.3803877 8.29759357,12.4035342 8.26680652,12.422993 C8.25568247,12.4299807 8.24404667,12.4367067 8.23212724,12.4429657 C8.21827569,12.4502504 8.20453886,12.4566485 8.1905951,12.4623894 C8.17802507,12.4675915 8.16473685,12.4724419 8.15119917,12.4767316 C8.13583471,12.481552 8.12047425,12.4856039 8.10498705,12.4889143 C8.09430622,12.4912471 8.08325248,12.4932298 8.07207924,12.494843 C8.05487076,12.4972949 8.03773477,12.498877 8.02056948,12.4995793 C8.01375728,12.4998604 8.00689494,12.5 8,12.5 L7.98043349,12.4996194 C7.96293275,12.4989382 7.94546098,12.4973429 7.92809589,12.4948333 L8,12.5 C7.96390296,12.5 7.92869933,12.4961748 7.89477235,12.4889078 C7.87952575,12.4856039 7.86416529,12.481552 7.84898836,12.4767587 C7.83526315,12.4724419 7.82197493,12.4675915 7.80896344,12.4622078 C7.79546114,12.4566485 7.78172431,12.4502504 7.76824181,12.443195 C7.75595333,12.4367067 7.74431753,12.4299807 7.73298968,12.422812 C7.72729809,12.4192668 7.72146362,12.4154054 7.7156945,12.4114088 L7.69785608,12.3984173 C7.68424576,12.3880797 7.67118132,12.3770608 7.65871357,12.3654113 L7.64644661,12.3535534 L3.64644661,8.35355339 C3.45118446,8.15829124 3.45118446,7.84170876 3.64644661,7.64644661 C3.82001296,7.47288026 4.08943736,7.45359511 4.2843055,7.58859116 L4.35355339,7.64644661 L7.5,10.793 L7.5,1.5 C7.5,1.22385763 7.72385763,1 8,1 Z\"\r\n                  fill=\"#71757F\"\r\n                ></path>\r\n              </g>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          class=\"mc-action-btn mc-toggle-btn\"\r\n          title=\"\u5C55\u5F00/\u6298\u53E0\"\r\n          (click)=\"toggleExpand()\"\r\n        >\r\n          <svg\r\n            width=\"16px\"\r\n            height=\"16px\"\r\n            viewBox=\"0 0 16 16\"\r\n            version=\"1.1\"\r\n            xmlns=\"http://www.w3.org/2000/svg\"\r\n            xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n          >\r\n            <g\r\n              stroke=\"none\"\r\n              stroke-width=\"1\"\r\n              fill=\"none\"\r\n              fill-rule=\"evenodd\"\r\n            >\r\n              <path\r\n                d=\"M4.715694,14.4114091 C4.910563,14.5464051 5.179987,14.5271201 5.353553,14.3535531 L5.353553,14.3535531 L7.99999988,11.7070001 L10.646447,14.3535531 L10.715694,14.4114091 C10.910563,14.5464051 11.179987,14.5271201 11.353553,14.3535531 C11.548816,14.1582911 11.548816,13.8417091 11.353553,13.6464471 L11.353553,13.6464471 L8.353553,10.6464471 L8.284306,10.5885911 C8.089437,10.4535951 7.820013,10.4728801 7.646447,10.6464471 L7.646447,10.6464471 L4.646447,13.6464471 L4.588591,13.7156941 C4.453595,13.9105631 4.47288,14.1799871 4.646447,14.3535531 L4.646447,14.3535531 L4.715694,14.4114091 Z M14.5,7.50000012 C14.776142,7.50000012 15,7.72385812 15,8.00000012 C15,8.27614212 14.776142,8.50000012 14.5,8.50000012 L1.5,8.50000012 C1.223858,8.50000012 1,8.27614212 1,8.00000012 C1,7.72385812 1.223858,7.50000012 1.5,7.50000012 L14.5,7.50000012 Z M8.284306,5.41140912 L8.353553,5.35355312 L11.353553,2.35355312 C11.548816,2.15829112 11.548816,1.84170912 11.353553,1.64644712 C11.179987,1.47288012 10.910563,1.45359512 10.715694,1.58859112 L10.646447,1.64644712 L7.99999988,4.29300012 L5.353553,1.64644712 C5.179987,1.47288012 4.910563,1.45359512 4.715694,1.58859112 L4.646447,1.64644712 C4.47288,1.82001312 4.453595,2.08943712 4.588591,2.28430612 L4.646447,2.35355312 L7.646447,5.35355312 C7.820013,5.52712012 8.089437,5.54640512 8.284306,5.41140912 Z\"\r\n                fill=\"#71757F\"\r\n                fill-rule=\"nonzero\"\r\n              ></path>\r\n            </g>\r\n          </svg>\r\n        </div>\r\n        <div\r\n          class=\"mc-action-btn mc-copy-btn\"\r\n          title=\"\u590D\u5236\"\r\n          (click)=\"copyCode()\"\r\n        >\r\n          @if(copied) {\r\n          <span>\r\n            <svg\r\n              width=\"16px\"\r\n              height=\"16px\"\r\n              viewBox=\"0 0 16 16\"\r\n              version=\"1.1\"\r\n              xmlns=\"http://www.w3.org/2000/svg\"\r\n              xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n            >\r\n              <defs>\r\n                <polygon\r\n                  id=\"path-1\"\r\n                  points=\"6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459\"\r\n                ></polygon>\r\n              </defs>\r\n              <g\r\n                id=\"status/whiteBG/correct\"\r\n                stroke=\"none\"\r\n                stroke-width=\"1\"\r\n                fill=\"none\"\r\n                fill-rule=\"evenodd\"\r\n              >\r\n                <mask id=\"mask-2\" fill=\"white\">\r\n                  <use xlink:href=\"#path-1\"></use>\r\n                </mask>\r\n                <use id=\"Mask\" fill=\"#3DCCA6\" xlink:href=\"#path-1\"></use>\r\n              </g>\r\n            </svg>\r\n          </span>\r\n          } @else {\r\n          <span>\r\n            <svg\r\n              width=\"16px\"\r\n              height=\"16px\"\r\n              viewBox=\"0 0 16 16\"\r\n              version=\"1.1\"\r\n              xmlns=\"http://www.w3.org/2000/svg\"\r\n              xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n            >\r\n              <g\r\n                id=\"\u9875\u9762-1\"\r\n                stroke=\"none\"\r\n                stroke-width=\"1\"\r\n                fill=\"none\"\r\n                fill-rule=\"evenodd\"\r\n              >\r\n                <g\r\n                  transform=\"translate(-592.000000, -204.000000)\"\r\n                >\r\n                  <g\r\n                    transform=\"translate(560.000000, 180.000000)\"\r\n                  >\r\n                    <text\r\n                      font-family=\"PingFangSC-Regular, PingFang SC\"\r\n                      font-size=\"12\"\r\n                      font-weight=\"normal\"\r\n                      line-spacing=\"16\"\r\n                      fill=\"#71757F\"\r\n                    >\r\n                      <tspan x=\"27.136\" y=\"61\">\u590D\u5236</tspan>\r\n                    </text>\r\n                  </g>\r\n                  <path\r\n                    d=\"M604.5,206 C605.279696,206 605.920449,206.594888 605.993133,207.35554 L606,207.5 L606,214.5 C606,215.279696 605.405112,215.920449 604.64446,215.993133 L604.5,216 L604,216 L604,216.5 C604,217.279696 603.405112,217.920449 602.64446,217.993133 L602.5,218 L595.5,218 C594.671573,218 594,217.328427 594,216.5 L594,216.5 L594,209.5 C594,208.671573 594.671573,208 595.5,208 L595.5,208 L596,208 L596,207.5 C596,206.720304 596.594888,206.079551 597.35554,206.006867 L597.5,206 L604.5,206 Z M602.5,209 L595.5,209 C595.223858,209 595,209.223858 595,209.5 L595,209.5 L595,216.5 C595,216.776142 595.223858,217 595.5,217 L595.5,217 L602.5,217 C602.776142,217 603,216.776142 603,216.5 L603,216.5 L603,209.5 C603,209.223858 602.776142,209 602.5,209 L602.5,209 Z M604.5,207 L597.5,207 C597.25454,207 597.050392,207.176875 597.008056,207.410124 L597,207.5 L597,208 L602.5,208 C603.279696,208 603.920449,208.594888 603.993133,209.35554 L604,209.5 L604,215 L604.5,215 C604.74546,215 604.949608,214.823125 604.991944,214.589876 L605,214.5 L605,207.5 C605,207.25454 604.823125,207.050392 604.589876,207.008056 L604.5,207 Z\"\r\n                    fill=\"#71757F\"\r\n                    fill-rule=\"nonzero\"\r\n                  ></path>\r\n                </g>\r\n              </g>\r\n            </svg>\r\n          </span>\r\n          }\r\n        </div>\r\n      </div>\r\n    </ng-container>\r\n    <ng-container *ngIf=\"actionsTemplate\">\r\n      <ng-template [ngTemplateOutlet]=\"actionsTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n    </ng-container>\r\n  </div>\r\n  <ng-container *ngIf=\"headerTemplate\">\r\n    <ng-template [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n  </ng-container>\r\n\r\n  <div [ngClass]=\"{ 'mc-block-hidden': !expanded }\" >\r\n    @if (showMermaidDiagram && isMermaid && !contentTemplate) {\r\n    <div class=\"mc-mermaid-content\" #mermaidContent></div>\r\n    } @else if(!contentTemplate) {\r\n    <pre #codeElementTemplate><code #codeElement [ngClass]=\"'hljs language-' + language\" ></code></pre>\r\n    } @else {\r\n    <ng-container *ngIf=\"contentTemplate\">\r\n      <ng-template [ngTemplateOutlet]=\"contentTemplate\" [ngTemplateOutletContext]=\"{ $implicit: {code, language}, codeBlockData: {code, language} }\"></ng-template>\r\n    </ng-container>\r\n    }\r\n  </div>\r\n</div>\r\n", styles: [".mc-markdown-render ::ng-deep .h1,.mc-markdown-render ::ng-deep .h2,.mc-markdown-render ::ng-deep .h3,.mc-markdown-render ::ng-deep .h4,.mc-markdown-render ::ng-deep .h5,.mc-markdown-render ::ng-deep .h6,.mc-markdown-render ::ng-deep h1,.mc-markdown-render ::ng-deep h2,.mc-markdown-render ::ng-deep h3,.mc-markdown-render ::ng-deep h4,.mc-markdown-render ::ng-deep h5,.mc-markdown-render ::ng-deep h6{line-height:1.1;margin:16px 0 12px}.mc-markdown-render ::ng-deep .h1:first-child,.mc-markdown-render ::ng-deep .h2:first-child,.mc-markdown-render ::ng-deep .h3:first-child,.mc-markdown-render ::ng-deep .h4:first-child,.mc-markdown-render ::ng-deep .h5:first-child,.mc-markdown-render ::ng-deep .h6:first-child,.mc-markdown-render ::ng-deep h1:first-child,.mc-markdown-render ::ng-deep h2:first-child,.mc-markdown-render ::ng-deep h3:first-child,.mc-markdown-render ::ng-deep h4:first-child,.mc-markdown-render ::ng-deep h5:first-child,.mc-markdown-render ::ng-deep h6:first-child{margin-top:0}.mc-markdown-render ::ng-deep h1{font-size:32px;line-height:40px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep h3{line-height:28px;font-size:20px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep caption{border:1px dashed var(--devui-line, #d7d8da);border-bottom:0;padding:3px;text-align:center}.mc-markdown-render ::ng-deep p{overflow-wrap:break-word;margin:0;padding:0;line-height:24px}.mc-markdown-render ::ng-deep p:last-child{margin:0}.mc-markdown-render ::ng-deep ul,.mc-markdown-render ::ng-deep ol{margin:0;padding:0;padding-inline-start:1.75em}.mc-markdown-render ::ng-deep ul>li,.mc-markdown-render ::ng-deep ol>li{line-height:21px}.mc-markdown-render ::ng-deep ul{list-style-type:disc}.mc-markdown-render ::ng-deep ul li::marker{font-size:20px}.mc-markdown-render ::ng-deep ol{list-style-type:decimal}.mc-markdown-render ::ng-deep table{margin-bottom:10px;border-collapse:collapse;display:table}.mc-markdown-render ::ng-deep td,.mc-markdown-render ::ng-deep th{padding:5px 10px;border:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-base-bg, #ffffff)}.mc-markdown-render ::ng-deep th{border-top:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-global-bg, #f6f6f8)}.mc-markdown-render ::ng-deep td p{margin:0;padding:0}.mc-markdown-render ::ng-deep blockquote{padding:0 8px;margin:0;color:var(--devui-text-weak, #575d6c);border-left:5px solid var(--devui-dividing-line, #f2f2f3)}.mc-markdown-render ::ng-deep a{color:var(--devui-link, #526ecc);text-decoration:none;cursor:pointer}.mc-markdown-render ::ng-deep a:hover{color:var(--devui-link-active, #526ecc)}.mc-markdown-render ::ng-deep img{max-width:100%}.mc-markdown-render{font-size:var(--devui-font-size, 14px);overflow-x:auto}.mc-markdown-render.mc-markdown-render-dark{color:#ced1db}.mc-markdown-render.mc-markdown-render-light{color:#252b3a}::ng-deep .mc-think-block{color:var(--devui-aide-text, #71757f);border-left:1px solid var(--devui-line, #d7d8da);padding-left:8px;margin-bottom:1rem}::ng-deep .mc-typewriter-color{background-image:-webkit-linear-gradient(left,#191919,#5588f0,#e171ee,#f2c55c);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-gradient{background:linear-gradient(to right,var(--devui-text, #252b3a),var(--devui-base-bg, #ffffff));background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-cursor{font-weight:900;animation:typewriter .8s linear 0s infinite}@keyframes typewriter{0%{opacity:1}50%{opacity:0}to{opacity:1}}.mc-code-block-light ::ng-deep pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-light ::ng-deep code.hljs{padding:3px 5px}.mc-code-block-light ::ng-deep .hljs{background:#fefefe;color:#545454}.mc-code-block-light ::ng-deep .hljs-comment,.mc-code-block-light ::ng-deep .hljs-quote{color:#696969}.mc-code-block-light ::ng-deep .hljs-variable,.mc-code-block-light ::ng-deep .hljs-template-variable,.mc-code-block-light ::ng-deep .hljs-tag,.mc-code-block-light ::ng-deep .hljs-name,.mc-code-block-light ::ng-deep .hljs-selector-id,.mc-code-block-light ::ng-deep .hljs-selector-class,.mc-code-block-light ::ng-deep .hljs-regexp,.mc-code-block-light ::ng-deep .hljs-deletion{color:#d91e18}.mc-code-block-light ::ng-deep .hljs-number,.mc-code-block-light ::ng-deep .hljs-built_in,.mc-code-block-light ::ng-deep .hljs-literal,.mc-code-block-light ::ng-deep .hljs-type,.mc-code-block-light ::ng-deep .hljs-params,.mc-code-block-light ::ng-deep .hljs-meta,.mc-code-block-light ::ng-deep .hljs-link{color:#aa5d00}.mc-code-block-light ::ng-deep .hljs-attribute{color:#aa5d00}.mc-code-block-light ::ng-deep .hljs-string,.mc-code-block-light ::ng-deep .hljs-symbol,.mc-code-block-light ::ng-deep .hljs-bullet,.mc-code-block-light ::ng-deep .hljs-addition{color:green}.mc-code-block-light ::ng-deep .hljs-title,.mc-code-block-light ::ng-deep .hljs-section{color:#007faa}.mc-code-block-light ::ng-deep .hljs-keyword,.mc-code-block-light ::ng-deep .hljs-selector-tag{color:#7928a1}.mc-code-block-light ::ng-deep .hljs-emphasis{font-style:italic}.mc-code-block-light ::ng-deep .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-light ::ng-deep .hljs-addition,.mc-code-block-light ::ng-deep .hljs-attribute,.mc-code-block-light ::ng-deep .hljs-built_in,.mc-code-block-light ::ng-deep .hljs-bullet,.mc-code-block-light ::ng-deep .hljs-comment,.mc-code-block-light ::ng-deep .hljs-link,.mc-code-block-light ::ng-deep .hljs-literal,.mc-code-block-light ::ng-deep .hljs-meta,.mc-code-block-light ::ng-deep .hljs-number,.mc-code-block-light ::ng-deep .hljs-params,.mc-code-block-light ::ng-deep .hljs-string,.mc-code-block-light ::ng-deep .hljs-symbol,.mc-code-block-light ::ng-deep .hljs-type,.mc-code-block-light ::ng-deep .hljs-quote{color:highlight}.mc-code-block-light ::ng-deep .hljs-keyword,.mc-code-block-light ::ng-deep .hljs-selector-tag{font-weight:700}}.mc-code-block-light{border:1px solid #d7d8da;background-color:#f5f5f5}.mc-code-block-light code.hljs{padding:1em}.mc-code-block-light .mc-code-lang,.mc-code-block-light .mc-code-block-actions .mc-copy-btn,.mc-code-block-light .mc-code-block-actions .mc-toggle-btn{color:#252b3a}.mc-code-block-light .mc-code-block-actions .mc-copy-btn:hover,.mc-code-block-light .mc-code-block-actions .mc-toggle-btn:hover{background-color:#ebebeb}.mc-code-block-light .mc-mermaid-content{background:#fefefe}.mc-code-block-dark ::ng-deep pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-dark ::ng-deep code.hljs{padding:3px 5px}.mc-code-block-dark ::ng-deep .hljs{background:#2b2b2b;color:#f8f8f2}.mc-code-block-dark ::ng-deep .hljs-comment,.mc-code-block-dark ::ng-deep .hljs-quote{color:#d4d0ab}.mc-code-block-dark ::ng-deep .hljs-variable,.mc-code-block-dark ::ng-deep .hljs-template-variable,.mc-code-block-dark ::ng-deep .hljs-tag,.mc-code-block-dark ::ng-deep .hljs-name,.mc-code-block-dark ::ng-deep .hljs-selector-id,.mc-code-block-dark ::ng-deep .hljs-selector-class,.mc-code-block-dark ::ng-deep .hljs-regexp,.mc-code-block-dark ::ng-deep .hljs-deletion{color:#ffa07a}.mc-code-block-dark ::ng-deep .hljs-number,.mc-code-block-dark ::ng-deep .hljs-built_in,.mc-code-block-dark ::ng-deep .hljs-literal,.mc-code-block-dark ::ng-deep .hljs-type,.mc-code-block-dark ::ng-deep .hljs-params,.mc-code-block-dark ::ng-deep .hljs-meta,.mc-code-block-dark ::ng-deep .hljs-link{color:#f5ab35}.mc-code-block-dark ::ng-deep .hljs-attribute{color:gold}.mc-code-block-dark ::ng-deep .hljs-string,.mc-code-block-dark ::ng-deep .hljs-symbol,.mc-code-block-dark ::ng-deep .hljs-bullet,.mc-code-block-dark ::ng-deep .hljs-addition{color:#abe338}.mc-code-block-dark ::ng-deep .hljs-title,.mc-code-block-dark ::ng-deep .hljs-section{color:#00e0e0}.mc-code-block-dark ::ng-deep .hljs-keyword,.mc-code-block-dark ::ng-deep .hljs-selector-tag{color:#dcc6e0}.mc-code-block-dark ::ng-deep .hljs-emphasis{font-style:italic}.mc-code-block-dark ::ng-deep .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-dark ::ng-deep .hljs-addition,.mc-code-block-dark ::ng-deep .hljs-attribute,.mc-code-block-dark ::ng-deep .hljs-built_in,.mc-code-block-dark ::ng-deep .hljs-bullet,.mc-code-block-dark ::ng-deep .hljs-comment,.mc-code-block-dark ::ng-deep .hljs-link,.mc-code-block-dark ::ng-deep .hljs-literal,.mc-code-block-dark ::ng-deep .hljs-meta,.mc-code-block-dark ::ng-deep .hljs-number,.mc-code-block-dark ::ng-deep .hljs-params,.mc-code-block-dark ::ng-deep .hljs-string,.mc-code-block-dark ::ng-deep .hljs-symbol,.mc-code-block-dark ::ng-deep .hljs-type,.mc-code-block-dark ::ng-deep .hljs-quote{color:highlight}.mc-code-block-dark ::ng-deep .hljs-keyword,.mc-code-block-dark ::ng-deep .hljs-selector-tag{font-weight:700}}.mc-code-block-dark{border:1px solid #4e5057;background-color:#34363a}.mc-code-block-dark code.hljs{padding:1em}.mc-code-block-dark .mc-code-lang,.mc-code-block-dark .mc-code-block-actions .mc-copy-btn,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn{color:#ced1db}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn:hover,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn:hover{background-color:#393a3e}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn img,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn img{filter:brightness(1.5)}.mc-code-block-dark .mc-mermaid-content{background:#2b2b2b!important}@keyframes collapse-expand{0%{opacity:0;max-height:0}to{opacity:1;max-height:1000px}}@keyframes collapse-collapse{0%{opacity:1;max-height:1000px}to{opacity:0;max-height:0}}.mc-block-hidden{display:none}.collapse-expanded{animation:collapse-expand .5s ease-out}.collapse-collapsed{animation:collapse-collapse .5s ease-in}.mc-code-block{margin:1rem 0;overflow:hidden;border-radius:14px}.mc-code-block pre{margin:0}.mc-code-block .mc-action-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box}.mc-code-block .mc-code-block-header{display:flex;justify-content:space-between;align-items:center;padding:.5rem 1rem}.mc-code-block .mc-code-block-header .mc-code-lang{font-size:14px}.mc-code-block .mc-mermaid-content{position:relative;width:100%;height:400px;overflow:hidden;background:inherit}.mc-code-block .mc-code-block-actions{display:flex;align-items:center}.mc-code-block .mc-code-block-actions .mc-copy-btn,.mc-code-block .mc-code-block-actions .mc-toggle-btn{cursor:pointer;border-radius:4px;font-size:18px;padding:4px}.mc-code-block .mc-diagram-switch{display:flex;align-items:center;list-style:none;margin:0;padding:2px;border-radius:4px;background-color:var(--devui-icon-hover-bg);position:relative;transition:all .3s ease;overflow:hidden;height:24px}.mc-code-block .mc-diagram-switch:before{content:\"\";position:absolute;top:2px;left:2px;width:calc(50% - 2px);height:calc(100% - 4px);background-color:var(--devui-base-bg);border-radius:4px;transition:transform .3s ease;box-shadow:0 1px 2px #0000001a;z-index:1}.mc-code-block .mc-diagram-switch.mc-show-code:before{transform:translate(100%)}.mc-code-block .mc-diagram-switch .mc-diagram-switch-active{text-shadow:0 0 .4px #252b3a}.mc-code-block .mc-diagram-switch li{position:relative;padding:0 8px;margin:0;font-size:12px;cursor:pointer;transition:color .3s ease;z-index:2}\n"] }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { code: [{
                type: Input
            }], language: [{
                type: Input
            }], blockIndex: [{
                type: Input
            }], theme: [{
                type: Input
            }], enableMermaid: [{
                type: Input
            }], mermaidConfig: [{
                type: Input
            }], contentTemplate: [{
                type: Input
            }], headerTemplate: [{
                type: Input
            }], actionsTemplate: [{
                type: Input
            }], rootRef: [{
                type: ViewChild,
                args: ['rootRef']
            }], mermaidContentRef: [{
                type: ViewChild,
                args: ['mermaidContent']
            }], codeElementRef: [{
                type: ViewChild,
                args: ['codeElement', { static: false }]
            }], codeElementTemplates: [{
                type: ViewChildren,
                args: ['codeElementTemplate']
            }] } });

const defaultTypingConfig = {
    step: 2,
    interval: 50,
    style: 'normal',
};

class MarkdownCardFoundation extends BaseFoundation {
    constructor(adapter) {
        super({ ...adapter });
        this.isToken = (node) => {
            return 'type' in node && 'content' in node;
        };
        this.typewriterEnd = () => {
            this.setState({ isTyping: false });
            this._adapter.typingEnd?.();
        };
        this.getThinkContent = (content, thinkOptions) => {
            const thinkClass = thinkOptions?.customClass || 'mc-think-block';
            return (content
                ?.replace('<think>', `<div class="${thinkClass}">`)
                ?.replace('</think>', '</div>') || '');
        };
        this.parseTypingContent = (content) => {
            const { typingOptions } = this.getProps();
            const { typingIndex } = this.getStates();
            content = content.slice(0, typingIndex) || '';
            const options = { ...defaultTypingConfig, ...typingOptions };
            if (options.style === 'cursor') {
                content += `<span class="mc-typewriter mc-typewriter-cursor">|</span>`;
            }
            else if (options.style === 'color' || options.style === 'gradient') {
                content =
                    content.slice(0, -5) +
                        `<span class="mc-typewriter mc-typewriter-${options.style}">${content.slice(-5)}</span>`;
            }
            return content || '';
        };
        this.parseContent = () => {
            const { content, thinkOptions, enableThink } = this.getProps();
            const { typing, isTyping } = this.getStates();
            let parseContent = content || '';
            if (typing && isTyping) {
                parseContent = this.parseTypingContent(content);
            }
            if (enableThink) {
                parseContent = this.getThinkContent(content, thinkOptions);
            }
            parseContent = this._adapter.parseContent(parseContent);
        };
        this.typewriterStart = () => {
            const { typingOptions } = this.getProps();
            const { timer } = this.getStates();
            if (timer) {
                clearTimeout(timer);
            }
            this.setState({ isTyping: true });
            this._adapter.typingStart?.();
            const options = { ...defaultTypingConfig, ...typingOptions };
            const typingStep = () => {
                const { typingIndex, content } = this.getStates();
                let step = options.step || 2;
                if (Array.isArray(options.step)) {
                    step =
                        options.step[0] +
                            Math.floor(Math.random() * (options.step[1] - options.step[0]));
                }
                let index = typingIndex + step;
                this.setState({ typingIndex: index });
                this.parseContent();
                this._adapter.typingEvent();
                if (index >= content.length) {
                    this.typewriterEnd();
                    this.parseContent();
                    return;
                }
                let typingTimeout = setTimeout(typingStep, typeof options.interval === 'number' ? options.interval : 50);
                this.setState({
                    timer: typingTimeout,
                });
            };
            let typingStepTimeout = setTimeout(typingStep);
            this.setState({
                timer: typingStepTimeout,
            });
        };
    }
}

// 判断是否自闭合标签
const isSelfClosingTag = (token) => {
    // 判断token.content里面是否包含完整的HTML结构（所有开始标签都有对应的结束标签）
    const content = token.content || '';
    // 检查是否是自闭合标签（如 <img />, <br /> 等）
    if (content.match(/<(\w+)[^>]*\/>/)) {
        return true;
    }
    // 检查是否包含完整的HTML结构
    const tagStack = [];
    const openTagRegex = /<(\w+)[^>]*>/g;
    const closeTagRegex = /<\/(\w+)>/g;
    let openMatch;
    let closeMatch;
    // 重置正则表达式的lastIndex
    openTagRegex.lastIndex = 0;
    closeTagRegex.lastIndex = 0;
    // 按顺序处理所有标签
    const allMatches = [];
    // 收集所有开始标签
    while ((openMatch = openTagRegex.exec(content)) !== null) {
        allMatches.push({
            type: 'open',
            tagName: openMatch[1],
            index: openMatch.index
        });
    }
    // 收集所有结束标签
    while ((closeMatch = closeTagRegex.exec(content)) !== null) {
        allMatches.push({
            type: 'close',
            tagName: closeMatch[1],
            index: closeMatch.index
        });
    }
    // 按位置排序
    allMatches.sort((a, b) => a.index - b.index);
    // 检查标签是否完全匹配
    for (const match of allMatches) {
        if (match.type === 'open') {
            tagStack.push(match.tagName);
        }
        else {
            if (tagStack.length === 0) {
                return false; // 没有对应的开始标签
            }
            const lastOpenTag = tagStack[tagStack.length - 1];
            if (lastOpenTag !== match.tagName) {
                return false; // 标签不匹配
            }
            tagStack.pop();
        }
    }
    // 只有当所有标签都正确匹配时，才认为是自闭合的
    return tagStack.length === 0;
};
// 判断是否是结束标签
const isClosingTag = (openToken, closeToken) => {
    const openContent = openToken?.content || '';
    const closeContent = closeToken?.content || '';
    const openTagMatch = openContent.match(/<(\w+)/);
    const closeTagMatch = closeContent.match(/<\/(\w+)/);
    if (openTagMatch && closeTagMatch) {
        return openTagMatch[1] === closeTagMatch[1];
    }
    return false;
};
// 创建ast树节点
const genTreeNode = (node) => {
    return {
        nodeType: node ? node.type.replace('_open', '') : 'root',
        openNode: node,
        closeNode: null,
        children: [],
        vNodeKey: node?.vNodeKey || ''
    };
};
// 匹配成对html token
const matchHtmlToken = (token, stack) => {
    // 简单排除单独的闭合标签
    const isCloseTag = token.content.startsWith('</');
    if (!stack.length) {
        token.nesting = isCloseTag ? 0 : 1;
        stack.push(token);
        return;
    }
    // 判断当前token是否是上一个html token的闭合标签
    const prevToken = stack[stack.length - 1];
    const closing = isClosingTag(prevToken, token);
    if (closing) {
        token.nesting = -1;
        stack.pop();
    }
    else {
        if (isCloseTag) {
            token.nesting = 0;
        }
        else {
            token.nesting = 1;
            stack.push(token);
        }
    }
};
const isValidTagName = (tagName) => {
    if (!tagName)
        return false;
    try {
        document.createElement(tagName);
        return true;
    }
    catch (error) {
        return false;
    }
};
const tokensToAst = (tokens) => {
    // 递归处理 inline 类型的 token
    const processInlineToken = (token) => {
        const node = genTreeNode(token);
        // 如果 token 有 children，递归处理它们
        if (token.children && token.children.length > 0) {
            node.children = tokensToAst(token.children);
        }
        return node;
    };
    // 创建根节点
    const rootNode = genTreeNode(null);
    let curr = rootNode;
    const stack = [];
    const htmlInlineTokenStack = [];
    const htmlBlockTokenStack = [];
    // 处理html token nesting值
    tokens.forEach((tok, idx) => {
        tok.vNodeKey = `mc-markdown-content-key-${idx}`;
        tok.tokenIndex = idx;
        if (tok.type.includes('html_')) {
            if (isSelfClosingTag(tok)) {
                tok.nesting = 0;
                return;
            }
            const stack = tok.type === 'html_block'
                ? htmlBlockTokenStack
                : htmlInlineTokenStack;
            matchHtmlToken(tok, stack);
        }
    });
    tokens.forEach((tok, idx) => {
        let tmp;
        if (tok.nesting === 1) {
            // 开始标签
            tmp = genTreeNode(tok);
            curr.children.push(tmp);
            stack.push(curr);
            curr = tmp;
        }
        else if (tok.nesting === -1) {
            // 结束标签
            curr.closeNode = tok;
            if (!stack.length) {
                throw new Error('AST stack underflow.');
            }
            tmp = stack.pop();
            curr = tmp;
        }
        else if (tok.nesting === 0) {
            // 自闭合标签或 inline 内容
            if (tok.type === 'inline' && tok.children && tok.children.length > 0) {
                // 对于 inline 类型，递归处理其 children
                const inlineNode = processInlineToken(tok);
                curr.children.push(inlineNode);
            }
            else {
                // 普通 token，直接添加
                curr.children.push(tok);
            }
        }
        else {
            throw new Error(`Invalid nesting level found in token index ${idx}.`);
        }
    });
    if (stack.length !== 0) {
        // throw new Error('Unbalanced block open/close tokens.');
    }
    return rootNode.children;
};
/**
 * 递归查找所有层级中 className 包含 code-block-wrapper 的 DIV 节点
 * @param {Array} vnodes - 待查找的 vnode 列表
 * @returns {Array} 符合条件的节点列表
 */
function findCodeBlockWrappers(vnodes) {
    const result = [];
    // 遍历当前层级的 vnode
    vnodes.forEach((node) => {
        // 检查当前节点是否符合条件
        if (node.nodeName === 'DIV' && node.className?.includes('code-block-wrapper')) {
            result.push(node);
        }
        // 递归处理子节点（如果存在子节点且为数组）
        if (node.childNodes?.length) {
            result.push(...findCodeBlockWrappers(node.childNodes));
        }
    });
    return result;
}
// 声明一个utils静态默认导出
var MdParserUtils = {
    isSelfClosingTag,
    isClosingTag,
    tokensToAst,
    genTreeNode,
    matchHtmlToken,
    isValidTagName,
    findCodeBlockWrappers,
};

class MarkdownCardComponent extends BaseComponent {
    constructor(renderer, cdr) {
        super();
        this.renderer = renderer;
        this.cdr = cdr;
        this.content = '';
        this.typing = false;
        this.enableThink = false;
        this.typingOptions = {};
        this.thinkOptions = {};
        this.mdOptions = {};
        this.mdPlugins = [];
        this.customXssRules = [];
        this.theme = 'light';
        this.enableMermaid = false;
        this.incrementalDom = true;
        this.mermaidConfig = {};
        this.actionsTemplate = null;
        this.headerTemplate = null;
        this.contentTemplate = null;
        // 组件缓存映射表，用于存储已创建的CodeBlockComponent实例
        this.codeBlockComponentsCache = new Map();
        this.afterMdtInit = new EventEmitter();
        this.mdRenderChange = new EventEmitter();
        this.typingStart = new EventEmitter();
        this.typingEvent = new EventEmitter();
        this.typingEnd = new EventEmitter();
        this.typingIndex = 0;
        this.isTyping = false;
        this.timer = null;
        this.parser = MdParserUtils;
        this.mdt = markdownit({
            breaks: true,
            linkify: true,
            html: true,
            highlight: (str, lang) => {
                // 与Vue组件保持一致的高亮处理
                return '';
            },
            ...this.mdOptions,
        });
        this.mdCardService = new MDCardService();
        this.foundation = new MarkdownCardFoundation(this.adapter);
    }
    ngOnInit() {
        this.mdCardService.setMdPlugins(this.mdPlugins || [], this.mdt);
        this.mdCardService.setCustomXssRules(this.customXssRules || []);
        this.parseContent();
        this.afterMdtInit.emit(this.mdt);
    }
    get adapter() {
        return {
            ...super.adapter,
            locale: (key, params) => this.adapter.locale(key, params),
            typingStart: () => this.typingStart.emit(),
            typingEnd: () => this.typingEnd.emit(),
            typingEvent: () => this.typingEvent.emit(),
            parseContent: (content) => {
                // 解析 Markdown 内容
                const tokens = this.mdt.parse(content, {});
                const ast = this.parser.tokensToAst(tokens);
                const vnodes = this.astToVnodes(ast);
                this.renderContent(vnodes);
            },
        };
    }
    ngOnChanges(changes) {
        if (changes['content']) {
            this.contentChange(changes['content']);
        }
        if (changes['customXssRules'] && !changes['customXssRules'].firstChange) {
            this.mdCardService.setCustomXssRules(this.customXssRules || []);
            this.parseContent();
        }
        if ((changes['enableThink'] && !changes['enableThink'].firstChange) ||
            (changes['thinkOptions'] && !changes['thinkOptions'].firstChange) ||
            (changes['theme'] && !changes['theme'].firstChange)) {
            this.parseContent();
        }
        if (changes['mdPlugins'] && !changes['mdPlugins'].firstChange) {
            this.mdCardService.setMdPlugins(this.mdPlugins || [], this.mdt);
            this.parseContent();
        }
    }
    contentChange(change) {
        if (this.content.indexOf(change.previousValue) === -1) {
            this.clearCodeBlockCache();
        }
        if (!this.typing) {
            this.typingIndex = this.content?.length || 0;
            this.parseContent();
        }
        else {
            if (this.content.indexOf(change.previousValue) === -1) {
                this.typingIndex = 0;
            }
            // 使用setTimeout模拟Vue的nextTick行为
            setTimeout(() => this.typewriterStart());
        }
    }
    parseContent() {
        this.foundation.parseContent();
    }
    renderContent(vnodes) {
        if (!this.markdownContainer || !this.markdownContainer.element) {
            return;
        }
        if (!this.incrementalDom) {
            this.renderContentNoDiff(vnodes);
            return;
        }
        const container = this.markdownContainer.element.nativeElement;
        const parser = new DOMParser();
        const newContainerDiv = parser.parseFromString(`<div></div>`, 'text/html');
        const codeBlockWrappers = this.parser.findCodeBlockWrappers(vnodes);
        vnodes.forEach((node) => {
            if (node &&
                (node.nodeType ||
                    typeof node === 'string' ||
                    node instanceof HTMLElement)) {
                if (codeBlockWrappers.includes(node)) {
                    newContainerDiv.body.firstChild?.appendChild(this.getEmptyCodeBlock(node));
                }
                else {
                    newContainerDiv.body.firstChild?.appendChild(node);
                }
            }
        });
        let newContainerDivHTML = newContainerDiv.body?.firstChild?.outerHTML || '';
        const filteredHTML = this.mdCardService.filterHtml(newContainerDivHTML);
        // 使用morphdom进行DOM更新
        const newElement = document.createElement('div');
        newElement.innerHTML = filteredHTML;
        morphdom(container, filteredHTML, {
            onBeforeElUpdated: (fromEl, toEl) => {
                if (fromEl.nodeName === 'DIV' &&
                    fromEl.classList.contains('code-block-wrapper') &&
                    toEl.nodeName === 'DIV' &&
                    toEl.classList.contains('code-block-wrapper') &&
                    fromEl.getAttribute('key') === toEl.getAttribute('key') &&
                    this.codeBlockComponentsCache.has(fromEl.getAttribute('key') || '')) {
                    return false;
                }
                return true;
            },
        });
        // 将codeBlockWrappers中的每个div元素替换container中的对应key属性的元素
        codeBlockWrappers.forEach((newCodeBlock) => {
            if (newCodeBlock &&
                newCodeBlock.attributes &&
                newCodeBlock.attributes.key) {
                const key = newCodeBlock?.attributes?.key?.value;
                const existingElement = container.querySelector(`[key="${key}"]`);
                if (existingElement &&
                    newCodeBlock instanceof HTMLElement &&
                    existingElement !== newCodeBlock &&
                    newCodeBlock?.firstChild) {
                    existingElement.firstChild && existingElement.firstChild.remove();
                    existingElement.appendChild(newCodeBlock?.firstChild);
                }
            }
        });
        this.mdRenderChange.emit(newContainerDivHTML);
    }
    getEmptyCodeBlock(node) {
        const codeNode = document.createElement('div');
        codeNode.className = 'code-block-wrapper';
        codeNode.setAttribute('key', node?.attributes?.key?.value);
        return codeNode;
    }
    astToVnodes(nodes) {
        return nodes.map((node) => this.processASTNode(node));
    }
    processASTNode(node) {
        if (node.nodeType === 'html_inline' || node.nodeType === 'html_block') {
            return this.processHTMLNode(node);
        }
        if (node.nodeType === 'inline') {
            return this.processInlineToken(node);
        }
        if (this.foundation.isToken(node)) {
            return this.processToken(node);
        }
        return this.processASTNodeInternal(node);
    }
    processHTMLNode(node) {
        if (!node.openNode?.content)
            return;
        const parser = new DOMParser();
        const tagName = node.nodeType === 'html_block' ? 'div' : 'span';
        const containerDocument = parser.parseFromString(`<${tagName}>${node.openNode.content}</${tagName}>`, 'text/html');
        const containerBody = containerDocument.body.firstChild;
        // 处理子节点
        if (node.children && node.children.length > 0) {
            node.children.forEach((child) => {
                const childVnode = this.processASTNode(child);
                if (childVnode && containerBody) {
                    (containerBody?.firstChild || containerBody).appendChild(childVnode);
                }
            });
        }
        return containerBody;
    }
    renderContentNoDiff(vnodes) {
        const container = this.markdownContainer.element.nativeElement;
        const newContentFragement = this.renderer.createElement('div');
        vnodes.forEach((node) => {
            if (node &&
                (node.nodeType ||
                    typeof node === 'string' ||
                    node instanceof HTMLElement)) {
                newContentFragement.appendChild(node);
            }
        });
        while (container.firstChild) {
            container.removeChild(container.firstChild);
        }
        container.appendChild(newContentFragement);
    }
    processInlineToken(node) {
        let html = '';
        try {
            if (!node.openNode) {
                return null;
            }
            html = this.mdt.renderer.render([node.openNode], this.mdt.options, {});
        }
        catch (error) {
            console.error('Error rendering inline token:', node);
            return null;
        }
        // 将HTML字符串转换为DOM节点
        const parser = new DOMParser();
        const doc = parser.parseFromString(`<div>${html}</div>`, 'text/html');
        const token = doc.body.firstChild;
        // 如果只有一个子节点，直接返回子节点而不是包含div
        if (token && token.childNodes.length === 1) {
            return token.firstChild;
        }
        return token;
    }
    processFenceNode(token) {
        const language = token.info?.replace(/<span\b[^>]*>/i, '').replace('</span>', '') || '';
        const code = token.content || '';
        return this.createCodeBlock(language, code, token.tokenIndex || 0);
    }
    processASTNodeInternal(node) {
        let tagName = 'div';
        if (node.openNode?.tag && this.parser.isValidTagName(node.openNode?.tag)) {
            tagName = node.openNode?.tag;
        }
        const element = this.renderer.createElement(tagName);
        // 设置属性
        if (node.openNode.attrs) {
            node.openNode.attrs.forEach(([key, value]) => {
                this.renderer.setAttribute(element, key, value);
            });
        }
        // 特殊处理fence类型的token
        if (node.openNode.type === 'fence') {
            return this.processFenceNode(node.openNode);
        }
        // 处理所有带tag的AST节点
        if (node.openNode?.tag) {
            let tagName = this.parser.isValidTagName(node.openNode?.tag)
                ? node.openNode?.tag
                : 'div';
            const element = this.renderer.createElement(tagName);
            // 递归处理所有子节点并添加到当前元素
            node.children.forEach((child) => {
                const childNode = this.processASTNode(child);
                if (childNode) {
                    element.appendChild(childNode);
                }
            });
            return element;
        }
        node.children.forEach((child) => {
            const childNode = this.processASTNode(child);
            if (childNode) {
                element.appendChild(childNode);
            }
        });
        return element;
    }
    processToken(token) {
        if (token.type === 'text') {
            return this.renderer.createText(token.content || '');
        }
        if (token.type === 'inline') {
            return this.processInlineToken(token);
        }
        if (token.type === 'fence') {
            return this.processFenceNode(token);
        }
        if (token.type === 'softbreak') {
            if (this.mdt.options.breaks) {
                return this.renderer.createElement('br');
            }
            else {
                return this.renderer.createText('\n');
            }
        }
        if (token.type === 'html_block' || token.type === 'html_inline') {
            const parser = new DOMParser();
            const tagName = token.type === 'html_block' ? 'div' : 'span';
            const doc = parser.parseFromString(`<${tagName}>${token.content}</${tagName}>`, 'text/html');
            const tokenDom = doc.body;
            // 如果只有一个子节点，直接返回子节点而不是包含div
            if (tokenDom.firstChild && tokenDom.childNodes.length === 1) {
                return tokenDom.firstChild;
            }
            return tokenDom;
        }
        if (token.tag) {
            const tagName = this.parser.isValidTagName(token.tag) ? token.tag : 'div';
            const element = this.renderer.createElement(tagName);
            if (token.attrs) {
                token.attrs.forEach(([key, value]) => {
                    this.renderer.setAttribute(element, key, value);
                });
            }
            // 设置内容
            if (token.content) {
                const textNode = this.renderer.createText(token.content);
                element.appendChild(textNode);
            }
            return element;
        }
        return this.renderer.createText(token.content || '');
    }
    createCodeBlock(language, code, blockIndex) {
        const key = `code-block-${blockIndex}`;
        // 检查缓存中是否已存在相同blockIndex的组件
        if (this.codeBlockComponentsCache.has(key)) {
            const cachedItem = this.codeBlockComponentsCache.get(key);
            if (cachedItem) {
                // 更新现有组件的属性
                const componentRef = cachedItem.componentRef;
                componentRef.setInput('language', language);
                componentRef.setInput('code', code);
                componentRef.setInput('theme', this.theme);
                // 触发变更检测
                componentRef.changeDetectorRef.detectChanges();
                // 返回缓存的容器，无需重新创建
                return cachedItem.container;
            }
        }
        // 缓存中不存在，创建新组件
        const codeBlockContainer = this.renderer.createElement('div');
        this.renderer.setAttribute(codeBlockContainer, 'key', key);
        const componentRef = this.markdownContainer.createComponent(CodeBlockComponent, {
            projectableNodes: [],
            injector: this.markdownContainer.injector,
        });
        // 设置组件属性
        componentRef.instance.language = language;
        componentRef.instance.code = code;
        componentRef.instance.blockIndex = blockIndex;
        componentRef.instance.theme = this.theme;
        componentRef.instance.enableMermaid = this.enableMermaid;
        componentRef.instance.mermaidConfig = this.mermaidConfig || {};
        componentRef.instance.actionsTemplate = this.actionsTemplate;
        componentRef.instance.headerTemplate = this.headerTemplate;
        componentRef.instance.contentTemplate = this.contentTemplate;
        // 触发变更检测
        componentRef.changeDetectorRef.detectChanges();
        // 将组件的DOM元素附加到容器中
        this.renderer.appendChild(codeBlockContainer, componentRef.location.nativeElement);
        // 添加样式类
        this.renderer.addClass(codeBlockContainer, 'code-block-wrapper');
        // 缓存组件实例和容器
        this.codeBlockComponentsCache.set(key, {
            componentRef: componentRef,
            container: codeBlockContainer,
        });
        // 返回创建的DOM容器
        return codeBlockContainer;
    }
    typewriterStart() {
        this.foundation.typewriterStart();
    }
    clearCodeBlockCache() {
        this.codeBlockComponentsCache.forEach((cachedItem) => {
            cachedItem.componentRef.destroy();
        });
        this.codeBlockComponentsCache.clear();
    }
    // 在组件销毁时清理缓存，避免内存泄漏
    ngOnDestroy() {
        this.clearCodeBlockCache();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.10", type: MarkdownCardComponent, isStandalone: false, selector: "mc-markdown-card", inputs: { content: "content", typing: "typing", enableThink: "enableThink", typingOptions: "typingOptions", thinkOptions: "thinkOptions", mdOptions: "mdOptions", mdPlugins: "mdPlugins", customXssRules: "customXssRules", theme: "theme", enableMermaid: "enableMermaid", incrementalDom: "incrementalDom", mermaidConfig: "mermaidConfig", actionsTemplate: "actionsTemplate", headerTemplate: "headerTemplate", contentTemplate: "contentTemplate" }, outputs: { afterMdtInit: "afterMdtInit", mdRenderChange: "mdRenderChange", typingStart: "typingStart", typingEvent: "typingEvent", typingEnd: "typingEnd" }, viewQueries: [{ propertyName: "markdownContainer", first: true, predicate: ["markdownContainer"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"mc-markdown-render\" [ngClass]=\"theme === 'dark' ? 'mc-markdown-render-dark' : 'mc-markdown-render-light'\">\r\n  <div #markdownContainer></div>\r\n</div>\r\n<ng-content></ng-content>", styles: [".mc-markdown-render ::ng-deep .h1,.mc-markdown-render ::ng-deep .h2,.mc-markdown-render ::ng-deep .h3,.mc-markdown-render ::ng-deep .h4,.mc-markdown-render ::ng-deep .h5,.mc-markdown-render ::ng-deep .h6,.mc-markdown-render ::ng-deep h1,.mc-markdown-render ::ng-deep h2,.mc-markdown-render ::ng-deep h3,.mc-markdown-render ::ng-deep h4,.mc-markdown-render ::ng-deep h5,.mc-markdown-render ::ng-deep h6{line-height:1.1;margin:16px 0 12px}.mc-markdown-render ::ng-deep .h1:first-child,.mc-markdown-render ::ng-deep .h2:first-child,.mc-markdown-render ::ng-deep .h3:first-child,.mc-markdown-render ::ng-deep .h4:first-child,.mc-markdown-render ::ng-deep .h5:first-child,.mc-markdown-render ::ng-deep .h6:first-child,.mc-markdown-render ::ng-deep h1:first-child,.mc-markdown-render ::ng-deep h2:first-child,.mc-markdown-render ::ng-deep h3:first-child,.mc-markdown-render ::ng-deep h4:first-child,.mc-markdown-render ::ng-deep h5:first-child,.mc-markdown-render ::ng-deep h6:first-child{margin-top:0}.mc-markdown-render ::ng-deep h1{font-size:32px;line-height:40px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep h3{line-height:28px;font-size:20px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep caption{border:1px dashed var(--devui-line, #d7d8da);border-bottom:0;padding:3px;text-align:center}.mc-markdown-render ::ng-deep p{overflow-wrap:break-word;margin:0;padding:0;line-height:24px}.mc-markdown-render ::ng-deep p:last-child{margin:0}.mc-markdown-render ::ng-deep ul,.mc-markdown-render ::ng-deep ol{margin:0;padding:0;padding-inline-start:1.75em}.mc-markdown-render ::ng-deep ul>li,.mc-markdown-render ::ng-deep ol>li{line-height:21px}.mc-markdown-render ::ng-deep ul{list-style-type:disc}.mc-markdown-render ::ng-deep ul li::marker{font-size:20px}.mc-markdown-render ::ng-deep ol{list-style-type:decimal}.mc-markdown-render ::ng-deep table{margin-bottom:10px;border-collapse:collapse;display:table}.mc-markdown-render ::ng-deep td,.mc-markdown-render ::ng-deep th{padding:5px 10px;border:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-base-bg, #ffffff)}.mc-markdown-render ::ng-deep th{border-top:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-global-bg, #f6f6f8)}.mc-markdown-render ::ng-deep td p{margin:0;padding:0}.mc-markdown-render ::ng-deep blockquote{padding:0 8px;margin:0;color:var(--devui-text-weak, #575d6c);border-left:5px solid var(--devui-dividing-line, #f2f2f3)}.mc-markdown-render ::ng-deep a{color:var(--devui-link, #526ecc);text-decoration:none;cursor:pointer}.mc-markdown-render ::ng-deep a:hover{color:var(--devui-link-active, #526ecc)}.mc-markdown-render ::ng-deep img{max-width:100%}.mc-markdown-render{font-size:var(--devui-font-size, 14px);overflow-x:auto}.mc-markdown-render.mc-markdown-render-dark{color:#ced1db}.mc-markdown-render.mc-markdown-render-light{color:#252b3a}::ng-deep .mc-think-block{color:var(--devui-aide-text, #71757f);border-left:1px solid var(--devui-line, #d7d8da);padding-left:8px;margin-bottom:1rem}::ng-deep .mc-typewriter-color{background-image:-webkit-linear-gradient(left,#191919,#5588f0,#e171ee,#f2c55c);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-gradient{background:linear-gradient(to right,var(--devui-text, #252b3a),var(--devui-base-bg, #ffffff));background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-cursor{font-weight:900;animation:typewriter .8s linear 0s infinite}@keyframes typewriter{0%{opacity:1}50%{opacity:0}to{opacity:1}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mc-markdown-card', standalone: false, template: "<div class=\"mc-markdown-render\" [ngClass]=\"theme === 'dark' ? 'mc-markdown-render-dark' : 'mc-markdown-render-light'\">\r\n  <div #markdownContainer></div>\r\n</div>\r\n<ng-content></ng-content>", styles: [".mc-markdown-render ::ng-deep .h1,.mc-markdown-render ::ng-deep .h2,.mc-markdown-render ::ng-deep .h3,.mc-markdown-render ::ng-deep .h4,.mc-markdown-render ::ng-deep .h5,.mc-markdown-render ::ng-deep .h6,.mc-markdown-render ::ng-deep h1,.mc-markdown-render ::ng-deep h2,.mc-markdown-render ::ng-deep h3,.mc-markdown-render ::ng-deep h4,.mc-markdown-render ::ng-deep h5,.mc-markdown-render ::ng-deep h6{line-height:1.1;margin:16px 0 12px}.mc-markdown-render ::ng-deep .h1:first-child,.mc-markdown-render ::ng-deep .h2:first-child,.mc-markdown-render ::ng-deep .h3:first-child,.mc-markdown-render ::ng-deep .h4:first-child,.mc-markdown-render ::ng-deep .h5:first-child,.mc-markdown-render ::ng-deep .h6:first-child,.mc-markdown-render ::ng-deep h1:first-child,.mc-markdown-render ::ng-deep h2:first-child,.mc-markdown-render ::ng-deep h3:first-child,.mc-markdown-render ::ng-deep h4:first-child,.mc-markdown-render ::ng-deep h5:first-child,.mc-markdown-render ::ng-deep h6:first-child{margin-top:0}.mc-markdown-render ::ng-deep h1{font-size:32px;line-height:40px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep h3{line-height:28px;font-size:20px;overflow-wrap:break-word}.mc-markdown-render ::ng-deep caption{border:1px dashed var(--devui-line, #d7d8da);border-bottom:0;padding:3px;text-align:center}.mc-markdown-render ::ng-deep p{overflow-wrap:break-word;margin:0;padding:0;line-height:24px}.mc-markdown-render ::ng-deep p:last-child{margin:0}.mc-markdown-render ::ng-deep ul,.mc-markdown-render ::ng-deep ol{margin:0;padding:0;padding-inline-start:1.75em}.mc-markdown-render ::ng-deep ul>li,.mc-markdown-render ::ng-deep ol>li{line-height:21px}.mc-markdown-render ::ng-deep ul{list-style-type:disc}.mc-markdown-render ::ng-deep ul li::marker{font-size:20px}.mc-markdown-render ::ng-deep ol{list-style-type:decimal}.mc-markdown-render ::ng-deep table{margin-bottom:10px;border-collapse:collapse;display:table}.mc-markdown-render ::ng-deep td,.mc-markdown-render ::ng-deep th{padding:5px 10px;border:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-base-bg, #ffffff)}.mc-markdown-render ::ng-deep th{border-top:1px solid var(--devui-dividing-line, #f2f2f3);background-color:var(--devui-global-bg, #f6f6f8)}.mc-markdown-render ::ng-deep td p{margin:0;padding:0}.mc-markdown-render ::ng-deep blockquote{padding:0 8px;margin:0;color:var(--devui-text-weak, #575d6c);border-left:5px solid var(--devui-dividing-line, #f2f2f3)}.mc-markdown-render ::ng-deep a{color:var(--devui-link, #526ecc);text-decoration:none;cursor:pointer}.mc-markdown-render ::ng-deep a:hover{color:var(--devui-link-active, #526ecc)}.mc-markdown-render ::ng-deep img{max-width:100%}.mc-markdown-render{font-size:var(--devui-font-size, 14px);overflow-x:auto}.mc-markdown-render.mc-markdown-render-dark{color:#ced1db}.mc-markdown-render.mc-markdown-render-light{color:#252b3a}::ng-deep .mc-think-block{color:var(--devui-aide-text, #71757f);border-left:1px solid var(--devui-line, #d7d8da);padding-left:8px;margin-bottom:1rem}::ng-deep .mc-typewriter-color{background-image:-webkit-linear-gradient(left,#191919,#5588f0,#e171ee,#f2c55c);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-gradient{background:linear-gradient(to right,var(--devui-text, #252b3a),var(--devui-base-bg, #ffffff));background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}::ng-deep .mc-typewriter-cursor{font-weight:900;animation:typewriter .8s linear 0s infinite}@keyframes typewriter{0%{opacity:1}50%{opacity:0}to{opacity:1}}\n"] }]
        }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }], propDecorators: { content: [{
                type: Input
            }], typing: [{
                type: Input
            }], enableThink: [{
                type: Input
            }], typingOptions: [{
                type: Input
            }], thinkOptions: [{
                type: Input
            }], mdOptions: [{
                type: Input
            }], mdPlugins: [{
                type: Input
            }], customXssRules: [{
                type: Input
            }], theme: [{
                type: Input
            }], enableMermaid: [{
                type: Input
            }], incrementalDom: [{
                type: Input
            }], mermaidConfig: [{
                type: Input
            }], actionsTemplate: [{
                type: Input
            }], headerTemplate: [{
                type: Input
            }], contentTemplate: [{
                type: Input
            }], afterMdtInit: [{
                type: Output
            }], mdRenderChange: [{
                type: Output
            }], typingStart: [{
                type: Output
            }], typingEvent: [{
                type: Output
            }], typingEnd: [{
                type: Output
            }], markdownContainer: [{
                type: ViewChild,
                args: ['markdownContainer', { read: ViewContainerRef, static: true }]
            }] } });

class MarkdownCardModule {
    static forRoot() {
        return {
            ngModule: MarkdownCardModule,
            providers: []
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardModule, declarations: [CodeBlockComponent,
            MarkdownCardComponent], imports: [CommonModule,
            TranslatePipe,
            LocaleModule], exports: [CodeBlockComponent,
            MarkdownCardComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardModule, imports: [CommonModule,
            LocaleModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MarkdownCardModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        CodeBlockComponent,
                        MarkdownCardComponent,
                    ],
                    imports: [
                        CommonModule,
                        TranslatePipe,
                        LocaleModule,
                    ],
                    exports: [
                        CodeBlockComponent,
                        MarkdownCardComponent
                    ],
                    providers: [],
                    bootstrap: []
                }]
        }] });

/*
 * Public API Surface of components-ng
 */

/**
 * Generated bundle index. Do not edit.
 */

export { AvatarBodyIconComponent, AvatarComponent, AvatarNoBodyIconComponent, BubbleComponent, BubbleLoadingComponent, BubbleModule, CodeBlockComponent, InputComponent, InputModule, LocaleModule, LocaleService, MarkdownCardComponent, MarkdownCardModule, TranslatePipe, inputContextToken };
//# sourceMappingURL=matechat-ng.mjs.map
